选择语言 :

 Core_Core::setup

系统启动

null Core_Core::setup( [ boolean $auto_execute = bool true ] )

参数列表

参数 类型 描述 默认值
$auto_execute boolean 是否直接运行 bool true
File: ./core/classes/core.class.php
public static function setup($auto_execute = true)
{
    static $run = null;

    if (null===$run)
    {
        $run = true;

        Core::$charset = Core::$config['charset'];

        if (!IS_CLI)
        {
            # 输出powered by信息
            $x_powered_by = (isset(Core::$config['hide_x_powered_by_header']) && Core::$config['hide_x_powered_by_header']) ? Core::$config['hide_x_powered_by_header'] : false;

            if (is_string($x_powered_by))
            {
                $str = 'X-Powered-By: ' . trim(str_replace(array("\r", "\n"), '', $x_powered_by));
            }
            else if (!$x_powered_by)
            {
                $str = 'X-Powered-By: PHP/' . PHP_VERSION . ' MyQEE/' . Core::VERSION .'('. Core::RELEASE .')';
            }
            else
            {
                $str = null;
            }

            if ($str)
            {
                header($str);
            }
        }

        if (IS_DEBUG)
        {
            Core::debug()->info('SERVER IP:' . $_SERVER["SERVER_ADDR"] . (function_exists('php_uname')?'. SERVER NAME:' . php_uname('a') : ''));

            if (Core::$project)
            {
                Core::debug()->info('project: ' . Core::$project);
            }

            if (IS_ADMIN_MODE)
            {
                Core::debug()->info('admin mode');
            }

            if (IS_REST_MODE)
            {
                Core::debug()->info('RESTFul mode');
            }

            Core::debug()->group('include path');
            foreach ( Core::include_path() as $value )
            {
                Core::debug()->log(Core::debug_path($value));
            }
            Core::debug()->groupEnd();
        }

        if ((IS_CLI || IS_DEBUG) && class_exists('ErrException', true))
        {
            # 注册脚本
            register_shutdown_function(array('ErrException', 'shutdown_handler'));
            # 捕获错误
            set_exception_handler(array('ErrException', 'exception_handler'));
            set_error_handler(array('ErrException', 'error_handler'), error_reporting());
        }
        else
        {
            # 注册脚本
            register_shutdown_function(array('Core', 'shutdown_handler'));
            # 捕获错误
            set_exception_handler(array('Core', 'exception_handler'));
            set_error_handler(array('Core', 'error_handler'), error_reporting());
        }

        if (!IS_CLI)
        {
            # 初始化 HttpIO 对象
            HttpIO::setup();
        }

        # 注册输出函数
        register_shutdown_function(array('Core', '_output_body'));

        if (true===IS_SYSTEM_MODE)
        {
            if (false===Core::check_system_request_allow())
            {
                # 内部请求验证不通过
                Core::show_500('system request hash error');
            }
        }

        if (IS_DEBUG && isset($_REQUEST['debug']) && class_exists('Profiler', true))
        {
            Profiler::setup();
        }

        if (!defined('URL_ASSETS'))
        {
            /**
             * 静态文件URL地址前缀
             *
             * @var string
             */
            define('URL_ASSETS', rtrim(Core::config('url.assets', Core::url('/assets/')), '/') . '/');
        }
    }

    if ($auto_execute)
    {
        Core::run();
    }
}