PHP Judgment class whether there is function class_exists usage analysis, function class_exists
This paper analyzes the existence of function class_exists usage of PHP judgment class. Share to everyone for your reference. Specific as follows:
If we want to determine whether a class is available, you can use the Class_exists function first to judge, here are a few examples.
BOOL Class_exists (String $class _name [, bool $autoload = True])
Whether the given class is defined by this feature is checked. This function checks whether, or not, the given class has been defined.
Returns True if Class_name is a defined class, otherwise returns FALSE.
Examples are as follows:
Copy the Code code as follows: function __autoload ($class)
{
Include ($class. '. php ');
Check to see whether the include declared the class
if (!class_exists ($class, false)) {
Trigger_error ("Unable to load class: $class", e_user_warning);
}
}
if (class_exists (' MyClass ')) {
$myclass = new MyClass ();
}
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/911905.html www.bkjia.com true http://www.bkjia.com/PHPjc/911905.html techarticle PHP Judgment class is the existence of function class_exists usage analysis, function class_exists This article analyzes the PHP judgment class whether there is function class_exists usage. Share to everyone for your reference. ...