phpget_called_class()函数与get_class()函数的区别
原创get_class (): 获取当前调用方法的类名(self);
get_called_class():获取静态绑定后的类名(static);
class Foo{
public function test(){
var_dump(get_class());
}
public function test2(){
var_dump(get_called_class());
}
public static function test3(){
var_dump(get_class());
}
public static function test4(){
var_dump(get_called_class());
}
}
class B extends Foo{
}
$B=new B();
$B->test();
$B->test2();
Foo::test3();
Foo::test4();
B::test3();
B::test4();
输出结果:
string Foo (length=3)
string B (length=1)
string Foo (length=3)
string Foo (length=3)
string Foo (length=3)
string B (length=1) 版权声明
所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除
itfan123


