Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Name binding
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Late static== Late static binding is a variant of binding somewhere between static and dynamic binding. Consider the following [[PHP]] example: <syntaxhighlight lang="php"> class A { public static $word = "hello"; public static function hello() { print self::$word; } } class B extends A { public static $word = "bye"; } B::hello(); </syntaxhighlight> In this example, the PHP interpreter binds the keyword <code>self</code> inside <code>A::hello()</code> to class <code>A</code>, and so the call to <code>B::hello()</code> produces the string "hello". If the semantics of <code>self::$word</code> 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.<ref>{{cite web|url=http://us2.php.net/manual/en/language.oop5.late-static-bindings.php|title=Late Static Bindings|access-date=July 3, 2013}}</ref> Specifically, if <code>self::$word</code> in the above were changed to <code>static::$word</code> as shown in the following block, where the keyword <code>static</code> would only be bound at runtime, then the result of the call to <code>B::hello()</code> would be "bye": <syntaxhighlight lang="php"> class A { public static $word = "hello"; public static function hello() { print static::$word; } } class B extends A { public static $word = "bye"; } B::hello(); </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)