Function name: spl_autoload_functions()
Applicable version: PHP 5 >= 5.1.0, PHP 7
Function Description: The spl_autoload_functions() function returns an array of all registered autoloading functions.
usage:
array spl_autoload_functions ( void )
Parameter description: None
Return value: Returns an array containing all registered autoloading functions, and if there is no registered autoloading function, an empty array is returned.
Example:
// 定义一个自动加载函数function myAutoload($class) { include 'classes/' . $class . '.php'; } // 注册自动加载函数spl_autoload_register('myAutoload'); // 获取所有已注册的自动加载函数$autoloadFunctions = spl_autoload_functions(); // 打印每个自动加载函数的名称foreach ($autoloadFunctions as $autoloadFunction) { echo $autoloadFunction . "<br>"; }
In the above example, we first define an automatic loading function named myAutoload()
to load the corresponding file according to the class name. Next, we register the autoload function into the autoload queue by calling spl_autoload_register()
function. Finally, we use the spl_autoload_functions()
function to get all registered autoload functions and print out the name of each autoload function by looping out.
Note: The spl_autoload_functions()
function has an important change in PHP 7, which now returns an associative array containing the autoload function and class name. If you want to get the name of the autoload function, you can use array_keys()
function to extract the keys of the array.