Reputation: 50
Testing some late static binding and getting this error on line 5:
Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE
line 5:
protected static test = 'A TEST';
Here is the source:
class A {
protected static test = 'A TEST';
public static function test() {
echo $this->test;
}
}
Class B extends A {
public static test = "B TEST";
public function static_test() {
echo static::$test;
}
}
$a = new A;
$b = new B;
echo '$a->test()<br />';
echo $a->test();
echo '<br /> <br />';
echo '$b->test()<br />';
echo $b->test();
echo '<br /> <br />';
echo '$b->static_test()<br />';
echo $b->static_test();
Safe to say I am stumped.
Upvotes: 1
Views: 3375
Reputation: 255155
protected static $test = 'A TEST';
^--- !!!
It's not a constant - so it should be preceded by $
sign
Upvotes: 5