1 方法一: 2 class foo { 3 static public function test() { 4 var_dump(get_called_class()); 5 } 6 } 7 8 class bar extends foo { 9 } 10 11 foo::test(); 12 bar::test(); 13 14 输出: 15 16 string(3) "foo" 17 string(3) "bar" 18 19 方法二: 20 class Bar { 21 public static function test() { 22 var_dump(static::class); 23 } 24 } 25 26 class Foo extends Bar { 27 28 } 29 30 Foo::test(); 31 Bar::test(); 32 33 Output: 34 35 string(3) "Foo" 36 string(3) "Bar"
原文:http://www.cnblogs.com/shijiu520/p/5740360.html