However, PHP is not an object-oriented language, but we must rely on it and always prepare this idea. Every time you use a class, you need to include the class file, which is very troublesome. it seems that "object" is not so easy.
Although PHP is not an object-oriented language, we must rely on it and always prepare this idea. Every time a class is used, it is very troublesome to include the class file. it seems that "object" is not so easy to be new. Now, the main character of today is to help us solve this problem. it is the _ autoload () function.
This function is a special function in php. it will be automatically called when trying to use a class that has not been defined, so that we can make a fuss about it, this is to write a code containing a class file. the usage is as follows:
Function _ autoload ($ class_name)
{
If (file_exists $ class_name. '. class. php '))
{
Require_once ($ class_name. '. class. php ');
}
}
In fact, this is so simple. we can write this function in the global configuration file to use the class at will. Note that the class file name must be consistent with the storage directory.