PHP. OOP. Static properties and methods

Главная » Tutorials » PHP » PHP. OOP. Static properties and methods

PHP supports static properties and methods. For declaration of static method or property php has got static keyword

Accessing to static properties and methods doesn’t suppose object creating. While trying to access a static property through class object you will get an error. But from php 5.3 you may access to static method through class object.
Intro static method you can’t use $this. It is true, because static property “glues” to class. $this suppose dynamic accessing to property or method.
Also we considered situation with accessing to own and parent static properties. Accessing to own class property intro static method realizes with self keyword. if you need to access a static parent property, you need to use parent keyword.

Подписаться на рассылку

Будьте в курсе - получайте последние статьи на свой email

Ваша подписка успешно оформлена

Pin It on Pinterest

Share This