spl_autoload_register()怎样注册多个自动加载函数?

 

<?php 

/*function __autoload($class){
    require("./class/".$class.".php");
}*/

function auto($class){
    require("./class/".$class.".php");
}
function aa($class){
    require("./class2/".$class.".php");
}

spl_autoload_register("auto");
spl_autoload_register("aa");

$cc=spl_autoload_functions();
var_dump($cc);

$a=new c();
$a->index();

 ?>

输出:

array(2) { [0]=> string(4) "auto" [1]=> string(2) "aa" } 
Warning: require(./class/c.php): failed to open stream: No such file or directory in D:wwwaauto.php on line 8

Fatal error: require(): Failed opening required './class/c.php' (include_path='.;C:phppear') in D:wwwaauto.php on line 8

文件:

原文地址:https://www.cnblogs.com/brady-wang/p/10681904.html