Static class property can be accessed as $object::$property?

php.internals

Jakub Kubíček

10 years ago
Hi, I'd be very thankful for a clear explanation on this: http://stackoverflow.com/questions/35656898 May be it's just a word game and I don't understand it correctly, but documentation states one, though $object::$staticProperty works in all versions (tested on 3v4l). Very best regards, Kubis Pandian-Fowler

Etienne Kneuss

10 years ago
On Fri, Feb 26, 2016 at 7:12 PM <kelerest123@gmail.com> wrote:
> Hi, > > > I'd be very thankful for a clear explanation on this: > http://stackoverflow.com/questions/35656898 > > > May be it's just a word game and I don't understand it correctly, but > documentation states one, though $object::$staticProperty works in all > versions (tested on 3v4l). >
$obj::$foo is a shortcut for $cl = get_class($obj); $cl::$foo; The static property is stored at the level of the class. What the documentation means is that you cannot access a static property using $obj->foo; you have to use "::" . Best,