Who can explain why this returns an error:
$test = new myclass();
class myclass {
private $object = (object) NULL;
public function addmember() {
Expressions are not allowed in a class body definition.
From php.net:
This declaration may include an initialization, but this initialization must be a constant value--that is, it must be able to be evaluated at compile time and must not depend on run-time information in order to be evaluated.
For example, you can not do this:
But can do this:
x = 1 + 2;
}
}
?>
Also, you can initialize property within a class body by constant value, that does not need to be evaluated on parse process: