Late/Delayed binding of the parent class and subclass in PHP

Source: Internet
Author: User
Post-binding/Delayed binding of the parent class and subclass in PHP & lt ;? Php & nbsp;/***** & nbsp; & nbsp; public welfare PHP Lecture Hall & nbsp; altar: & nbsp; http://www.zixue.it & nbsp; Micro & nbsp; blog: PHP in the parent class and subclass of the late binding/delay binding
  1. /****
  2. Yan 18 public welfare PHP Lecture Hall
  3.  
  4. Discussion: http://www.zixue.it
  5. Micro Bo: http://weibo.com/Yshiba
  6. YY Channel: 88354001
  7. ****/
  8. /***
  9. === Note ====
  10. Post-binding/Delayed binding
  11. ***/
  12. Class Human {
  13. Public static function whoami (){
  14. Echo 'whoami from parent class is being executed ';
  15. }
  16. Public static function say (){
  17. Self: whoami (); // There is no say method in the subclass. the parent class is found here.
  18. // Here self refers to the parent class
  19. }
  20. Public static function say2 (){
  21. Static: whoami (); // The sub-class does not have the say2 method. find the parent class here.
  22. // But the parent class uses static: whoami,
  23. // Call your own whoami method.
  24. }
  25. }
  26. Class Stu extends Human {
  27. /*
  28. Public static function whoami (){
  29. Echo 'from subclass whoami is being executed ';
  30. }
  31. */
  32. }
  33. Stu: say ();
  34. Stu: say2 ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.