Spl_autoload_register (PHP5 & gt; 5.1.2) spl_autoload_register & mdash; register _ autoload () function description boolspl_autoload_register ([callback $ autoload_function])
Spl_autoload_register
(PHP 5> = 5.1.2)
Spl_autoload_register-register _ autoload () function
Description
Bool spl_autoload_register ([callback $ autoload_function])
Register the function to the SPL _ autoload function stack. If the functions in the stack are not activated, activate them.
If the _ autoload function has been implemented in your program, it must be explicitly registered to the _ autoload stack. Because
The spl_autoload_register () function replaces the _ autoload function in Zend Engine with spl_autoload () or spl_autoload_call ().
Parameters
Autoload_function
The automatically loaded function to be registered. If no parameter is provided, the default implementation function spl_autoload () of autoload is automatically registered ().
Return value
If the call succeeds, TRUE is returned. if the call fails, FALSE is returned.
Note: SPL is the abbreviation of Standard PHP Library (Standard PHP Library. It is an extension library introduced by PHP5. its main functions include the implementation of the autoload mechanism and various Iterator interfaces or classes. The implementation of the SPL autoload mechanism is achieved by pointing the function pointer autoload_func to the self-implemented function with the automatic loading function. SPL has two different functions: spl_autoload and spl_autoload_call. different automatic loading mechanisms are implemented by pointing autoload_func to these two function addresses.
Example
Load. php file
Class LOAD {static function loadClass ($ class_name) {$ filename = $ class_name. ". class. php "; $ path =" include /". $ filename; if (is_file ($ path) return include $ path ;}}/*** sets the automatic loading of an object * spl_autoload_register-Register given function as _ autoload () implementation */spl_autoload_register (array ('load', 'loadclass');/*** _ autoload method will expire after spl_autoload_register, because the autoload_func function pointer has pointed to the spl_autoload method *, you can use the following method to add the _ autoload method to the autoload_functions list */spl_autoload_register ('_ autoload ');
If you use spl_autoload_register to register a class method and the _ autoload function,
According to the registration sequence, if the class file is loaded in the first registered method or function, the method or function of the second registered class will no longer be executed. Otherwise, the method or function of the second registered class will be executed.