The method for a subclass in php to call the static method of the parent class: [parent::method()] or [self::method()]. If you want to call it outside the subclass, use [Subclass instance->method()].
Accessing parent class static member properties or methods within a subclass
(Recommended tutorial: php video tutorial)
parent::method()/self::method()
Note: $this->staticProperty (static properties of parent class cannot be accessed through $this (subclass instance), an error will be reported:
:PHP Strict Standards: Accessing static property Person::$country as non static in,PHP Notice: Undefined property: )
External access to subclass
Subclass name::method()
Subclass instance->method() (static methods can also be accessed through ordinary objects)
Note: Subclass Class instance->staticProperty (static properties of the parent class cannot be accessed through subclass instances, an error will be reported:
:PHP Strict Standards: Accessing static property Person::$country as non static in,PHP Notice: Undefined property: )
Related recommendations: php training
The above is the detailed content of How to call the static method of the parent class in PHP. For more information, please follow other related articles on the PHP Chinese website!