码迷,mamicode.com
首页 > Web开发 > 详细

PHP中spl_autoload_register()函数

时间:2015-03-08 22:50:39      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:

spl_autoload_register — 注册给定的函数作为 __autoload 的实现

官方地址:http://php.net/manual/zh/function.spl-autoload-register.php

我的测试

定义三个文件test.php test1.php test2.php

test.php

<?php

spl_autoload_register(autoLoad1);

test1::test();
echo "<br/>"; test2::test(); function autoLoad1($
class) { require $class..php; }

 

test1.php

<?php

class test1 {
    static public function test() {
        echo __FILE__;
    }    
}

 

test2.php

<?php

class test2 {
    static public function test() {
        echo __FILE__;
    }    
}    

 

运行test.php

技术分享

 

PHP中spl_autoload_register()函数

标签:

原文地址:http://www.cnblogs.com/wangkongming/p/4322462.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!