[PHP] __autoload function will be called when class_exists does not exist

The definition of this function is as follows:

class_exists ( string $class_name [, bool $autoload = true ]): bool

The second parameter is whether to automatically call the autoload function

class name. The matching of names is not partition case. 

autoload calls __autoload by default.

Of course, it is now recommended to use the following function for automatic loading

spl_autoload_register(function ($class_name) { 
    require_once $class_name. ' .php ' ; 

If you don’t want to call, give false as the second parameter

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *