Foo.php
abstract class Foo{
protected static $Bar;
public __construct(){
Foo::$Bar = "foobar";
}
}
Foo2.php
//require_once Foo.php
class Foo2 extends Foo{
public static function Func(){
echo Foo::$Bar;
}
}
End point
//require_once Foo2.php
Foo2::Func();
Then the page shows nothing. It should write "foobar". What am I doing wrong?
If I write
protected static $Bar = "foobar";
The code works for the 80% of cases. But there is a problem:
protected static $Bar = new AnotherClass();
Parse error: syntax error, unexpected 'new' (T_NEW)