English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP 基础教程

PHP 高级教程

PHP & MySQL

PHP 参考手册

PHP get_called_class() 函数用法及示例

PHP Class/Object 函数参考手册

 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"

PHP Class/Object 函数参考手册