Late bound/deferred binding of parent class and subclass in PHP
-
- /****
- Yan 18 Public welfare PHP Auditorium
- Forum: http://www.zixue.it
- Weibo: Http://weibo.com/Yshiba
- yy Channel: 88354001
- ****/
- /***
- = = = = Note Part = =
- late binding/late binding
- ***/
- class Human {
- public static function WhoAmI () {
- echo ' WhoAmI from the parent class is executing
';
- }
- public static function say () {
- Self::whoami (); There is no say method within the subclass, found the parent class here
- //The self here refers to the parent class
- }
- public static function Say2 () {
- static:: WhoAmI (); //Subclass also has no Say2 method, and find the parent class here
- //But the parent class uses Static::whoami,
- //refers to calling your subclass's own WhoAmI method
- }
- }
- class Stu extends human{
- /*
- Public static function WhoAmI () {
- Echo ' WhoAmI from sub-class is executing
';
- }
- */
- }
- Stu::say ();
- Stu::say2 ();