This article mainly introduces the PHP parent class to invoke the subclass method code example, need friends can refer to the following
The discovery today of the need to call subclasses in the parent class has never been used before and is also possible through practice. Examples such as: code as follows: <?php/** * Parent class Invoke subclass method base class * @author LNMP100 * */class Baseapp { / * * * calling subclass method * @version creation time: 2013-07-10 */ function _run_action () { $action = "index"; & nbsp $this-> $action (); }} class Defaultapp extends Baseapp { /** * This method will be tuned in the parent class */ function index () { echo "De Faultapp->index () invoked "; } function go () { //Calling parent class p Arent::_run_action (); } $default =new Defaultapp (); $default->go (); will display Defaultapp->index () invoked ?> &NBSP; But it feels like it's not a parent-class, it's a subclass of the way it is, because instantiation is a subclass, and if you instantiate the parent class, then you have a problem with the way the class is typed.