Given class MyClass with static property $var:
class MyClass
{
public static $var = 42;
}
To access MyClass::$var in class method method():
class MyClass
{
public static $var = 42;
public function method()
{
self::$var;
}
}
Notice how the syntax is
self::$var.
To access a class property when it’s not static:
class MyClass
{
public $var = 42;
public function method()
{
$this->var;
}
}
Notice how the syntax is
$this->var.
See static properties for more details.