Home >Backend Development >PHP Tutorial >小弟我的spl_auto_register()函数为什么只能注册一个自动加载函数呢

小弟我的spl_auto_register()函数为什么只能注册一个自动加载函数呢

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 12:11:36955browse

我的spl_auto_register()函数为什么只能注册一个自动加载函数呢?

------解决思路----------------------
两个都可以注册成功,你的autoload函数require之前 先要判断是否是文件啊,亲

<br /><br />function __autoload1($className) {    <br />    $path = 'class/' . $className . ".class.php";<br />    if (is_file($path))<br />        require_once 'class/' . $className . ".class.php";<br />}<br />function __autoload2($phpFile) {<br />    $path = $phpFile . ".class.php";<br />    echo $path;<br />    if (is_file($path))<br />        require_once $phpFile . ".class.php";<br />}<br />spl_autoload_register('__autoload1');<br />spl_autoload_register('__autoload2');<br />$page = new Page;<br />$person = new Person();<br />print_r($page);<br />print_r($person);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn