include.php
<?php
$include = array('test');
set_include_path(get_include_path() . PATH_SEPARATOR .implode(PATH_SEPARATOR, $include));
class Loader
{
/**
* 自动加载类
* @param $class 类名
*/
public static function autoload($class)
{
$path = '';
$path = $class. '.php';
@include_once($path);
}
}
/**
* spl自动加载
*/
spl_autoload_register(array('Loader', 'autoload'));
使用时只需要include ‘include.php’;即可以