Today, we suddenly found that the subclass method needs to be called in the parent class, which has never been used before. It can also be found through practice. Example:
Copy codeThe Code is as follows:
<? Php
/**
* The parent class calls the subclass method base class.
* @ Author LNMP100
*
*/
Class BaseApp
{
/**
* Call The subclass Method
* @ Version Creation Time:
*/
Function _ run_action ()
{
$ Action = "index ";
$ This-> $ action ();
}
}
Class DefaultApp extends BaseApp
{
/**
* This method will be called in the parent class
*/
Function index ()
{
Echo "DefaultApp-> index () invoked ";
}
Function Go (){
// Call the parent class
Parent: _ run_action ();
}
}
$ Default = new defaapp app ();
$ Default-> Go ();
// DefaultApp-> index () invoked will be displayed
?>
However, it seems that this is not the parent class's subclass, but the method that the subclass calls itself, because the instantiation is a subclass. If you instantiate the parent class, there is a problem with the method that the subclass can be called.