According to the php documentation http://php.net/manual/en/language.oop5.constants.php
A property declared as static can not be accessed with an instantiated class object
But doesn't the following example show that you can access a static property from the object $foo
?
class Foo{
static $my_static = 'foo';
function staticValue(){
return self::$my_static;
}
}
$foo = new Foo();
echo $foo::$my_static;
The trick here is that you are using the scope resolution operator :: which always references the class. It doesn't matter if you use $foo or $this or self.
Self is a keyword in PHP that references the current level, but :: can be used on an object to gain reference to the class for that object. self:: is in the same family of keywords as parent::, think of self:: as wanting access to something at the current level of an object, and parent:: as wanting access to something below the current object.
Therefore, to access something that is defined in the class. PHP created the :: operator. If you just need something from the class that is static, then you can use self inside the class or an object reference outside it.