<?php define('CHAR_TRUE', '1'); define('CHAR_FALSE', '0'); define('NOW', isset($_SERVER['REQUEST_TIME']) ? $_SERVER['REQUEST_TIME'] : time()); define('IS_POST', isset($_SERVER['REQUEST_METHOD']) && !strcasecmp($_SERVER['REQUEST_METHOD'], 'POST')); define('IS_GET', isset($_SERVER['REQUEST_METHOD']) && !strcasecmp($_SERVER['REQUEST_METHOD'], 'GET')); define('IS_PUT', isset($_SERVER['REQUEST_METHOD']) && !strcasecmp($_SERVER['REQUEST_METHOD'], 'PUT')); define('IS_DELETE', isset($_SERVER['REQUEST_METHOD']) && !strcasecmp($_SERVER['REQUEST_METHOD'], 'DELETE')); define('IS_CLI', PHP_SAPI == 'cli'); define('IS_AJAX', isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && strtolower($_SERVER["HTTP_X_REQUESTED_WITH"]) == "xmlhttprequest"); define('PATH_VENDOR', realpath(__DIR__ . "/../../") . '\\'); //基础目录(绝对) define('PATH_BASE', PATH_VENDOR . '../'); // 整个代码的根目录 define('PATH_LI', dirname(__FILE__)); // 框架目录(绝对) define('PATH_APP_REL', dirname($_SERVER['SCRIPT_NAME'])); // 当前APP的相对路径 include PATH_VENDOR . "autoload.php"; \Li\App::init()->run();
public static function autoload($className) { if (isset(self::$_coreClasses[$className])) { require_once PATH_LI . self::$_coreClasses[$className]; } else { // 无命名空间 if (strpos($className, '\\') === false) { if (isset(App::app()->config['import']) && is_array(App::app()->config['import'])) { foreach (\Li\App::app()->config['import'] as $path) { $classFile = PATH_APP . 'core' . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $className . '.php'; if (is_file($classFile)) { include $classFile; } } } } else { // 命名空间 $path = explode('\\', $className); $classFile = PATH_APP . 'core' . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $path) . '.php'; if (is_file($classFile)) { include $classFile; } } return class_exists($className, false) || interface_exists($className, false); } return true; }