get_called_class
(PHP 5 >= 5.3.0)
get_called_class — the "Late Static Binding" class name
说明
string get_called_class ( void )Gets the name of the class the static method is called in.
返回值
Returns the class name. Returns FALSE if called from outside a class.
范例
Example #1 Using get_called_class() 以上例程会输出:
<?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"
参见
- get_parent_class() - 返回对象或类的父类名
- get_class() - 返回对象的类名
- is_subclass_of() - 如果此对象是该类的子类,则返回 TRUE