Name Binding - Late Static

Late Static

Late static binding is a variant of binding somewhere between static and dynamic binding. Consider the following PHP example:

class A { static $word = "hello"; static function hello {print self::$word;} } class B extends A { static $word = "bye"; } B::hello;

In this example, the PHP interpreter binds the function hello to class A, and so the call to B::hello produces the string "hello". If the semantics of "self::$word" had been based on "late static binding", then the result would have been "bye".

Beginning with PHP version 5.3, late static binding is supported . Specifically, if "self::$word" in the above were changed to "static::$word" as shown in the following block, then the result of the call to B::hello would be "bye":

class A { static $word = "hello"; static function hello {print static::$word;} } class B extends A { static $word = "bye"; } B::hello;

Read more about this topic:  Name Binding

Famous quotes containing the word late:

    Roosevelt could always keep ahead with his work, but I cannot do it, and I know it is a grievous fault, but it is too late to remedy it. The country must take me as it found me. Wasn’t it your mother who had a servant girl who said it was no use for her to try to hurry, that she was a “Sunday chil” and no “Sunday chil” could hurry? I don’t think I am a Sunday child, but I ought to have been; then I would have had an excuse for always being late.
    William Howard Taft (1857–1930)