php get_called_class()函数与get_class函数的区别
2017-09-14 11:40
441 查看
get_class (): 获取当前调用方法的类名;
get_called_class():获取静态绑定后的类名;
public function test5(){ var_dump(get_class()); }
}
$B=new B();
$B->test();
$B->test2();
Foo::test3();
Foo::test4();
B::test3();
B::test4();
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
string
'B' (length=1)
string
'B' (length=1)
get_called_class():获取静态绑定后的类名;
有例为证:
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{
public function test5(){ var_dump(get_class()); }
}
$B=new B();
$B->test();
$B->test2();
Foo::test3();
Foo::test4();
B::test3();
B::test4();
B::test5();1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
输出结果: string 'Foo' (length=3) string 'B' (length=1) string 'Foo' (length=3) string 'Foo' (length=3) string 'Foo' (length=3) string 'B' (length=1)
string 'B' (length=1) string 'B' (length=1)
string
'B' (length=1)
string
'B' (length=1)
相关文章推荐
- 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中file() 函数和file_get_contents() 函数的区别
- PHP的继承方法如何获取子类名?get_class() 和 get_called_class
- PHP中get_class($this)与__CLASS__的区别
- php对象:__autoload()函数及单入口文件,__set(), __get(), get_class_methods(),get_class_vars()
- PHP的继承方法如何获取子类名?get_class() 和 get_called_class()
- 【php趣味】__CLASS__、get_class、get_called_class三兄弟
- PHP中func_get_args系列函数的区别
- 让PHP<5.3版本支持get_called_class()方法
- PHP中的get_called_class
- php使用get_class_methods()函数获取分类的方法
- php get_class()函数
- php中的get_called_class()方法
- PHP的继承方法如何获取子类名?get_class() 和 get_called_class()
- php使用get_class_methods()函数获取分类的方法