PHP's own framework implements debug debugging mode and time zone (Improvement Part 3)

1. To achieve the effect, switch debug mode through config settings.

 

 

 

 2. Debug mode setting and time zone setting

Click for detailed explanation of error_reporting and display_errors

   public static function run(){
        //定义常量
        self::_set_const();

        //创建模块目录
        self::_mk_module();
        //加载文件
        self::_import_file();
        self::_set_system();
        //类自动加载
        spl_autoload_register(array(__CLASS__,'_autoload'));
        //运行框架
        self::_run();
    }
    //设置调试模式debug
    private static function _set_system(){
        if(config('DEBUG')){
            error_reporting(E_ALL);
            ini_set('display_errors', 'On');
        }else{
            error_reporting(0);
            ini_set('display_errors', 'Off');
        }
        date_default_timezone_set(config('DEFAYLT_TIME_ZONE'));
    }

3. Set config.php to enable debugging mode and time zone

<?php
return [
    'DB_HOST'=>'localhost',//数据库地址
    'DB_DATABASE'=>'test',//数据库
    'DB_USER'=>'root',//数据库账号
    'DB_PWD'=>'root',//数据库密码
    'DEBUG'=>false,//调试模式
    "DEFAYLT_TIME_ZONE"=>"PRC",//设置时区

];

Guess you like

Origin blog.csdn.net/weixin_39934453/article/details/132372338