get_called_class
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
get_called_class — The "Late Static Binding" class name
Параметри
У цієї функції немає
параметрів.
Значення, що повертаються
Returns the class name.
Помилки/виключення
If get_called_class() is called from outside a class,
an Error is thrown. Prior to PHP 8.0.0,
an E_WARNING level error was raised.
Приклади
Приклад #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"