Exemplo n.º 1
0
<?php

require APP_PATH . "config.php";
require APP_PATH . "functions.php";
AutoLoadClass::Register();
APP::Init();
//自动装载类
class AutoLoadClass
{
    public static function Register()
    {
        if (function_exists('__autoload')) {
            spl_autoload_register('__autoload');
        }
        return spl_autoload_register(array('AutoLoadClass', 'Load'));
    }
    public static function Load($pClassName)
    {
        //echo "load:$pClassName<br>";
        $pClassName = str_replace("\\", "/", $pClassName);
        $class = substr($pClassName, strrpos($pClassName, '/') + 1);
        //echo "$class\n";
        if (class_exists($class, FALSE)) {
            return false;
        }
        $classPath = APP_PATH . $pClassName . '.class.php';
        if (file_exists($classPath) === FALSE || is_readable($classPath) === FALSE) {
            return false;
        }
        require_once $classPath;
    }