kobra
kobra

Reputation: 4963

Static properties in PHP

When are static properties initialized, as I know other member properties are initialized when object is created.

Thanks

Upvotes: 1

Views: 153

Answers (2)

mauris
mauris

Reputation: 43619

Static properties? Do you mean static variables or methods?

Either way, they are initialized when the script is parsed, or the class is defined.

Upvotes: 1

miku
miku

Reputation: 188034

Declaring class properties or methods as static makes them accessible without needing an instantiation of the class. A property declared as static can not be accessed with an instantiated class object (though a static method can).

/ http://php.net/manual/en/language.oop5.static.php

So, they are available after they have been declared.

Upvotes: 2

Related Questions