If we want to judge whether a class can be used, we can first use the class_exists function to judge. Let’s look at a few examples.
bool class_exists ( string $class_name [, bool $autoload = true ] )
Whether this function The given class is defined and checked, returning true if class_name is a defined class, otherwise returning false.
php example code is as follows:
if (class_exists('myclass')) {
$myclass = new myclass( );
}
function __autoload($class)
{
include($class . '.php');
if ( !class_exists($class, false)) {
!
$ myclass = new myclass();
}//Open source code phpfensi.com