PHP late static binding instance sharing

Source: Internet
Author: User
1. Late static binding works by storing the class name on the previous "non-forwarding call" (Non-forwarding calls). When a static method call is made, the class name is the one that is explicitly specified (usually in the left part of the: operator), and the class to which the object belongs when a non-static method call is made. This feature is named "Late static binding" from the perspective of the language itself. Late binding means that static:: It is no longer parsed to define the class in which the current method resides, but is calculated at the actual run time.

2. Test Example:

Class A{public    function run ()    {        static::test ();//late static binding        self::test ();//not late static binding    }    Public static function test ()    {        echo ' A class<br> ';    }} Class B extends a{public    static function test ()   {        echo ' B class<br> ';    }} $a = new B (); $a->run ();//output//b class//a Class
Related Article

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: 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.