Created
February 20, 2015 15:12
-
-
Save e0ipso/c0e314325c3c1653c87b to your computer and use it in GitHub Desktop.
About constant overrides and Late Static Binding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class A { | |
const C = 'Class A'; | |
public static function constantSelf() { | |
print self::C . PHP_EOL; | |
} | |
public static function constantStatic() { | |
print static::C . PHP_EOL; | |
} | |
} | |
class B extends A { | |
const C = 'Class B'; | |
} | |
print A::constantSelf(); | |
print B::constantSelf(); | |
print A::constantStatic(); | |
print B::constantStatic(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>$ php constants.php | |
Class A | |
Class A | |
Class A | |
Class B |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment