Output result: My name is Foo My name is Foo Its name is Foo get_class function (PHP 4, PHP 5) get_class — Returns the class name of the object Report a bug reject note description string get_class ([ object $obj ] ) Returns the name of the class to which the object instance obj belongs. Returns FALSE if obj is not an object. Note: Classes defined in PHP extension libraries return the name of their original definition. In PHP 4 get_class() returned the lowercase form of the user-defined class name, but in PHP 5 it will return the name of the class name as it was defined, just like the class name in the extension library. Note: Since PHP 5, obj is optional if called within a method of an object. Example 1, using get_class()
output: Its name is foo My name is foo |