get_called_class - 后期靜態(tài)綁定("Late Static Binding")類的名稱
get_called_class ( void );
獲取靜態(tài)方法調(diào)用的類名。
| 序號(hào) | 參數(shù)及說明 |
|---|---|
| 1 | void void 表示不需要任何參數(shù)。 |
返回類的名稱,如果不是在類中調(diào)用則返回 FALSE。
以下是此函數(shù)的用法-
<?php
class foo {
static public function test() {
var_dump(get_called_class());
}
}
class bar extends foo {
}
foo::test();
bar::test();
?>測試看看 ?/?輸出結(jié)果:
string(3) "foo" string(3) "bar"