1 普通静态绑定
<?php class A { public static function who() { echo __CLASS__.PHP_EOL; } public static function test() { self::who(); } } class B extends A { public static function who() { echo __CLASS__.PHP_EOL; } } B::test(); ?>
输出:
A
2 后期静态绑定
<?php class A { public static function who() { echo __CLASS__.PHP_EOL; } public static function test() { static::who(); } } class B extends A { public static function who() { echo __CLASS__.PHP_EOL; } } B::test(); ?>
输出:
B