I’m getting this error whenever I attempt to declare a class:
Parse error: syntax error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or
T_FUNCTION or T_VAR or '}' in /home3/foundloc/public_html/booka/page2.php
on line 7 (line 7 is the class declaration by the way).
Here’s the incredibly simple class I am attempting to declare:
Class abc
{
$a = “Hello!”;
}
Is there some setting on PHP that i need to turn on? I feel like this is one of those ‘did you check if the TV is plugged in’ type of issues….
You can’t declare properties in classes like that. Members of a class can be either data members (constants and properties) or methods. In the PHP 5 way of doing things, this is basically how it works:
You should really not consider using the php 4 practice of declaring data members with the
varkeyword, unless you are still developing for php 4 of course.