Php determines whether the class has class_exists usage analysis, and the function class_exists. Php determines whether the class has the function class_exists usage analysis. the Function class_exists This article analyzes the php judgment whether the class has the function class_exists usage. Share it with you for your reference. Use php to determine whether the class has the function class_exists usage analysis, the function class_exists
This article analyzes the usage of the php function class_exists to determine whether a class exists. Share it with you for your reference. The details are as follows:
If we want to determine whether a class can be used, we can use the class_exists function to determine whether a class can be used. Here are several examples.
Bool class_exists (string $ class_name [, bool $ autoload = true])
Whether the class specified by this function is defined and checked. This function checks whether or not the given class has been defined.
Returns true. if class_name is a defined class, otherwise, false is returned.
Example:
The code is 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 will help you with PHP programming.
Examples in this article analyze the usage of the php function class_exists to determine whether a class exists. Share it with you for your reference. With...