get_class返回对象实例的类名称
/**
* Returns the name of the class of an object
* @link https://php.net/manual/en/function.get-class.php
* @param object $object [optional] <p>
* The tested object. This parameter may be omitted when inside a class.
* </p>
* @return string|false <p>The name of the class of which <i>object</i> is an
* instance. Returns false if <i>object</i> is not an
* object.
* </p>
* <p>
* If <i>object</i> is omitted when inside a class, the
* name of that class is returned.
*/
function get_class ($object = null) {}
示例:
class Animal{
public function eat()
{
return 'eat';
}
}
$animal = new Animal();
var_dump(get_class($animal));//string(6) "Animal"
|