How to get the class name in PHP?
In PHP, you can retrieve the class name to which an object belongs by using the get_class() function. The syntax is as follows:
get_class(object $object): string|false
The parameter $object is the object from which the class name is to be obtained. The function returns a string representing the class name, and false if it fails.
Here is an example:
class MyClass {
}
$object = new MyClass();
$className = get_class($object);
echo $className; // 输出:MyClass