<?PHPclassa {Private functionfun1 () {Echo' A1 '; } //protected can be inherited, but can only be used in subclasses and cannot be instantiated for invocation protected functionfun2 () {Echo' A2 '; } Public functionFun3 () {Echo' A3 '; }}classBextendsa{ Public function__construct () {$this-fun2 (); } Public functionFun3 () {Echo' B3 '; } Public functionFun4 () {Echo' B4 '; Parent::Fun3 (); }}$b=Newb ();//call the constructor. Call the fun2 of parent Class A, output A2$b->fun3 ();//call overload after own fun3, output B3$b->fun4 ();//call your own fun4, output b4, and then call the parent class's FUN3 (parent: Call the version that is not overloaded, the original of the parents), output a3//$b->fun2 ()//error, because PROTECD can only be inherited and cannot be called in an instance object
PHP protected can only be inherited, can not be called in the instance, parent:: Call the parent class (the overload of the subclass function has no effect on the function of the parent class)