Why do I get this error when trying to set up a class variable
- by Jennifer
I'm new to PHP so maybe I am overlooking something here but the following:
class someClass {
var $id = $_GET['id'];
function sayHello() {
echo "Hello";
}
}
gives the following error:
Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\files\classes.php on line 13
If instead of $_GET['id'] I set the variable $id to a string, everything is fine though.