English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Class/Object function reference manual
The get_class() function returns the class name of the object
get_class ( $object );
This function gets the class name of the given object.
Serial number | Parameters and description |
---|---|
1 | object(Required) The object to be tested. This parameter can be omitted if it is in the class. |
It returns the name of the class of the object. If the object is not an object, it returns FALSE.
The following is the usage of this function, returning the name of the instance object-
<?php class f1 { function f1() { // Implement some logic } function name() { echo "My name is " , get_class($this) , "\n"; } } //Create an object $bar = new f1(); // External call echo "Its name is " , get_class($bar) , "\n"; // Internal call $bar->name(); ?>Test and see‹/›
It will produce the following result-
Its name is f1 My name is f1