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:\www\a\auto.php on line 8

Fatal error: require(): Failed opening required './class/c.php' (include_path='.;C:\php\pear') in D:\www\a\auto.php on line 8

文件:

 

posted @ 2019-04-10 10:41  brady-wang  阅读(1029)  评论(0编辑  收藏  举报