Home > Article > Backend Development > How to call parent class method in php subclass
php The method for a subclass to call the parent class method: [$this->Method name ()]. If there is this method in the subclass, the method in the subclass is called. If not, then The method in the parent class is called.
Method call:
(Learning video recommendation: java video tutorial)
$this->方法名();
If there is this method in the subclass, the method in the subclass is called, if not, the method in the parent class is called.
parent::
Always call the method in the parent class.
Variable calling:
$this->变量名;
If there is this variable in the subclass, the variable in the subclass will be called. If not, the variable in the parent class will be called.
Related recommendations: php training
The above is the detailed content of How to call parent class method in php subclass. For more information, please follow other related articles on the PHP Chinese website!