I’m a complete roockie at this, hoping you can help.
I get the syntax error when i pass the db.php.
{“exception”:0,”message”:”syntax error, unexpected ‘private’ (T_PRIVATE), expecting variable (T_VARIABLE)”,”file”:”/###/db.php”,”line”:8}
My code on that file is this:
class Database
{
private ?PDO $conn = null;
public function __construct(
private string $host,
private string $name,
private string $user,
private string $password
) {
}
public function getConnection(): ?PDO
{
I have looked at the tutorial here on stackoverflow: Include, getting “PHP Parse error: syntax error, unexpected ‘private’ (T_PRIVATE)”
But it’s from 2016 and i didn’t know if it’s still current.
I think it makes sense that I’m passing private, public in one class, not good right?
Can anyone find an example of what i should be doing properly?
Remember, i’m a complete roockie, and any copy n’ paste code examples would help me best…
Wishing you the best day.
Steve
I am trying to access my databaase through a JSON tutorial, but i am in the early phase and any JSON pass is not happening as atm i cannot even access my sample files, with the connection code, as it calls the syntax error.