类的自动加载

每次用类都要引入文件,烦不烦

php5可以用 spl_autoload_register()函数,不建议使用_autoload()函数。

spl_autoload_register(function($class_name){
   require_once $class_name.".php";
})

可以注册多个加载器function

如果前面的加载器没有找到,就会使用下一个加载器


首页 我的博客
粤ICP备17103704号