php get_called_class()函数与get_class函数的区别
2017-12-20 10:40
363 查看
简介
get_class (): 获取当前调用方法的类名;get_called_class():获取静态绑定后的类名;
代码
<?php class Foo{ public function test(){ var_dump(get_class()); echo "<br/>"; } public function test2(){ var_dump(get_called_class()); echo "<br/>"; } public static function test3(){ var_dump(get_class()); echo "<br/>"; } public static function test4(){ var_dump(get_called_class()); echo "<br/>"; } } class B extends Foo< 4000 /span>{ } $B=new B(); $B->test();//获取当前调用方法的类名 $B->test2();//获取静态绑定后的类名 Foo::test3();//获取静态绑定后的类名 Foo::test4();//获取静态绑定后的类名 B::test3();//获取当前调用方法的类名 B::test4();//获取静态绑定后的类名
运行结果
相关文章推荐
- php get_called_class()函数与get_class函数的区别
- php get_called_class()函数与get_class函数的区别
- [转]PHP __CLASS__、get_class()与get_called_class()的区别
- php __CLASS__、get_class()与get_called_class()的区别
- php __CLASS__、get_class()与get_called_class()的区别
- php __CLASS__、get_class()与get_called_class()的区别
- PHP中的get_called_class
- 让PHP<5.3版本支持get_called_class()方法
- php对象:__autoload()函数及单入口文件,__set(), __get(), get_class_methods(),get_class_vars()
- PHP中func_get_args系列函数的区别
- PHP中file() 函数和file_get_contents() 函数的区别
- PHP的继承方法如何获取子类名?get_class() 和 get_called_class
- PHP中get_class($this)与__CLASS__的区别
- PHP的继承方法如何获取子类名?get_class() 和 get_called_class()
- PHP的继承方法如何获取子类名?get_class() 和 get_called_class()
- PHP get_called_class
- php使用get_class_methods()函数获取分类的方法
- php中的get_called_class()方法
- php使用get_class_methods()函数获取分类的方法
- 【php趣味】__CLASS__、get_class、get_called_class三兄弟