PHP function __autoload can implement simple automatic loading, but after the introduction of Smarty found that the __autoload function is invalid, and later found to be the reason for the Spl_autoload_register function.
Execute the following code:
function __autoload ($name) {require ' class/'. $name. PHP '; Echo ' 1 ';} function Autoload_test ($name) {echo ' 2 ';} Spl_autoload_register (' autoload_test '); $ca =new CA ();
Output 2, you can see that the __autoload function is not executed, the official website of the resolution is: if you have implemented the __autoload () function in your program, it must be explicitly registered in the __autoload () queue. Because the Spl_autoload_register () function replaces the __autoload () function in Zend Engine with spl_autoload () or Spl_autoload_call ().
In order for the code to work properly, you should reregister the __autoload function:
function __autoload ($name) {require ' class/'. $name. PHP '; Echo ' 1 ';} function Autoload_test ($name) {echo ' 2 ';} Spl_autoload_register (' autoload_test '); Spl_autoload_register (' __autoload '); $ca =new CA ();
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The above describes the PHP function __autoload failure reason (related to smarty), including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.