Line: return 'Static hello ' . self::static_user . '...<br />';
Produces: Fatal error: Undefined class constant 'static_user' in ....
Note: Logic might be silly but I'm just playing wit it at the moment. Question is how can I access to static variable of abstract class in child class? I can access to public one $public_user with $this->public_user in child class.
abstract class UserAbstract
{
protected $public_user = null;
static protected $static_user = null;
public function __construct($name)
{
$this->public_user = $name;
self::$static_user = $name;
}
abstract static function static_hello();
}
class User extends UserAbstract
{
static function static_hello()
{
return 'Static hello ' . self::static_user . '...<br />';
}
}
$obj_user = new User('Voodoo');
echo $obj_user->static_hello();