get_called_class - 后期静态绑定("Late Static Binding")类的名称
get_called_class ( void );
获取静态方法调用的类名。
| 序号 | 参数及说明 |
|---|---|
| 1 | void void 表示不需要任何参数。 |
返回类的名称,如果不是在类中调用则返回 FALSE。
以下是此函数的用法-
<?php
class foo {
static public function test() {
var_dump(get_called_class());
}
}
class bar extends foo {
}
foo::test();
bar::test();
?>测试看看 ‹/›输出结果:
string(3) "foo" string(3) "bar"