array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.get-called-class.php', 1 => 'get_called_class', ), 'up' => array ( 0 => 'ref.classobj.php', 1 => '类/对象 函数', ), 'prev' => array ( 0 => 'function.enum-exists.php', 1 => 'enum_exists', ), 'next' => array ( 0 => 'function.get-class-methods.php', 1 => 'get_class_methods', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/classobj/functions/get-called-class.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
get_called_class — 后期静态绑定("Late Static Binding")类的名称
此函数没有参数。
返回类的名称。
示例 #1 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"