PHP Dokumentation: Function get-called-class
12. Januar 2010 von werner
get_called_class
(PHP 5 >= 5.3.0)
get_called_class — the "Late Static Binding" class name
Beschreibung
string get_called_class ( void )
Gets the name of the class the static method is called in.
Rückgabewerte
Returns the class name. Returns FALSE if called from outside a class.
Beispiele
Beispiel #1 Using get_called_class()
<?phpclass foo {
static public function test() {
var_dump(get_called_class());
}
}class
bar extends foo {
}foo::test();
bar::test();?>Das oben gezeigte Beispiel erzeugt folgendeAusgabe:
string(3) "foo"string(3) "bar"
Siehe auch
- get_parent_class() – Gibt den Namen der Elternklasse eines Objektes zurück
- get_class() – Ermittelt den Klassennamen eines Objekts
- is_subclass_of() – Prüft ob ein Objekt von der angegebenen Klasse abstammt