public function run() { session_start(); //路由 $this->route(); //链接数据库 require_once ROOT . '/../System/Class/db.class.php'; $db_config = (require_once ROOT . '/../Config/db.php'); SELF::$db = new db($db_config['db_host'], $db_config['db_user'], $db_config['db_password'], $db_config['db_name'], 'utf8'); if (file_exists(ROOT . '/../Controller/' . $this->controller_id . 'Controller.php')) { include_once ROOT . '/../Controller/' . $this->controller_id . 'Controller.php'; } else { exit(ROOT . '/../Controller/' . $this->controller_id . 'Controller.php not exists'); } //执行Controller $controller_class = $this->controller_id . 'Controller'; if (class_exists($controller_class)) { $controller_obj = new $controller_class(); if (method_exists($controller_obj, 'init')) { $controller_obj->init(); } $action_function = $this->action_id; echo $controller_obj->{$action_function}(); } else { exit($controller_class . ' not exists'); } SELF::$db->close(); }