PHP函数检查是否可以创建某种类型的对象?

It would take too long to explain why I need this, but I was wondering if there was a PHP function to check if a type of object was recognized. In other words, a function that would check if

$dog = new Dog();

would cause an error, because Dog didn't exist. Thanks for you help.

There is a function called class_exists

For further explanation, see the PHP manual page.

http://php.net/manual/en/function.class-exists.php

See class_exists. I think it is what you want. OR you can just wrap it with a try catch block.

Hope this helps.