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

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP reference manual

PHP get_called_class() function usage and example

PHP Class/Object function reference manual

 get_called_class - Late Static Binding ("Late Static Binding") class name

Syntax

get_called_class(void);

Definition and usage

 Get the class name of the static method call.

Parameter

NumberParameters and descriptions
1

void

void indicates that no parameters are required.

Return value

 Returns the class name, returns FALSE if not called within a class.

Online example

The following is the usage of this function-

<?php
class foo {
    static public function test() {
        var_dump(get_called_class());
    }
}
class bar extends foo {
}
foo::test();
bar::test();
?>
Test and see ‹/›

Output result:

string(3)  "foo"
string(3)  "bar"

PHP Class/Object function reference manual