get_class() returns the class name of the object you pass to it.
string get_class ([ object $object = NULL ] )
Returns the name of the class of which object is an instance. Returns FALSE if object is not an object.
If object is omitted when inside a class, the name of that class is returned.
Get the class name
<?php//from ww w .java 2 s . c om
class foo {
function name()
{
echo "My name is " , get_class($this) , "\n";
}
}
$bar = new foo();
echo "Its name is " , get_class($bar) , "\n";
$bar->name();
?>
The code above generates the following result.