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:

    Notwithstanding the unaccountable apathy with which of late years the Indians have been sometimes abandoned to their enemies, it is not to be doubted that it is the good pleasure and the understanding of all humane persons in the Republic, of the men and the matrons sitting in the thriving independent families all over the land, that they shall be duly cared for; that they shall taste justice and love from all to whom we have delegated the office of dealing with them.
    Ralph Waldo Emerson (1803–1882)