Late bound/delayed binding of parent class and subclass in PHP

Source: Internet
Author: User
Late bound/deferred binding of parent class and subclass in PHP
  1. /****
  2. Yan 18 Public welfare PHP Auditorium
  3. Forum: http://www.zixue.it
  4. Weibo: Http://weibo.com/Yshiba
  5. yy Channel: 88354001
  6. ****/
  7. /***
  8. = = = = Note Part = =
  9. late binding/late binding
  10. ***/
  11. class Human {
  12. public static function WhoAmI () {
  13. echo ' WhoAmI from the parent class is executing
    ';
  14. }
  15. public static function say () {
  16. Self::whoami (); There is no say method within the subclass, found the parent class here
  17. //The self here refers to the parent class
  18. }
  19. public static function Say2 () {
  20. static:: WhoAmI (); //Subclass also has no Say2 method, and find the parent class here
  21. //But the parent class uses Static::whoami,
  22. //refers to calling your subclass's own WhoAmI method
  23. }
  24. }
  25. class Stu extends human{
  26. /*
  27. Public static function WhoAmI () {
  28. Echo ' WhoAmI from sub-class is executing
    ';
  29. }
  30. */
  31. }
  32. Stu::say ();
  33. 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.