Created
December 10, 2013 07:27
-
-
Save miyukki/7886940 to your computer and use it in GitHub Desktop.
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 { | |
public static $name = "ClassA"; | |
public static function printStatic() { | |
echo static::$name.PHP_EOL; | |
} | |
public static function printSelf() { | |
echo self::$name.PHP_EOL; | |
} | |
} | |
class B extends A { | |
public static $name = "ClassB"; | |
} | |
class C extends A { | |
public static $name = "ClassC"; | |
public static function printStatic() { | |
echo static::$name.PHP_EOL; | |
} | |
public static function printSelf() { | |
echo self::$name.PHP_EOL; | |
} | |
} | |
A::printStatic(); // ClassA | |
A::printSelf(); // ClassA | |
B::printStatic(); // ClassB | |
B::printSelf(); // ClassA | |
C::printStatic(); // ClassC | |
C::printSelf(); // ClassC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment