自动加载器 autoloader.php
spl_autoload_register(function($class){
require $class. '.php';
});
a.php
namespace zuoye\controller;
class a
{
public static function index()
{
return __METHOD__;
}
b.php
namespace zuoye\controller;
class b
{
public static function index()
{
return __METHOD__;
}
c.php
namespace zuoye\controller;
class c
{
public static function index()
{
return __METHOD__;
}
入口文件 zuoye.php
namespace zuoye;
require __DIR__ . '/controller/a.php';
require __DIR__ . '/controller/b.php';
require __DIR__ . '/controller/c.php';
echo controller\a::index().'<br>';
echo controller\b::index().'<br>';
echo controller\c::index().'<br>';