zoukankan      html  css  js  c++  java
  • CodeIgniter 常量ENVIRONMENT设置要注意的地方

    http://bbs.phpchina.com/thread-274514-1-1.html

    index.php ,这是CodeIgniter的入口文件,做开发是,都会设置一下
    define('ENVIRONMENT', 'development');
    用来区分线上和线下环境,但是在这里

    if (defined('ENVIRONMENT'))
    {
        switch (ENVIRONMENT)
        {
            case 'development':
                error_reporting(E_ALL);
            break;
     
            case 'testing':
            case 'production':
                error_reporting(0);
            break;
     
            default:
                exit('The application environment is not set correctly.');
        }
    }
    

      CodeIgniter会判断一下,如果是production,它会将error_reporting设置为0,这会导致所有的错误都不记录php_error.log,但是error.log是我们发现bug和解决问题的重要依据。
    所以,根据我们自己的经验,建议CodeIgniter用户将error_reporting(0),这段代码删掉,并将php.ini的
    error_reporting=E_ALL&~E_NOTICE
    display_errors = Off
    如果你不能操作ini,那么就

    if (defined('ENVIRONMENT'))
    {
        switch (ENVIRONMENT)
        {
            case 'development':
                error_reporting(E_ALL);
            break;
     
            case 'testing':
            case 'production':
                error_reporting(E_ALL ^ E_NOTICE);
                ini_set('display_errors','0');
            break;
     
            default:
                exit('The application environment is not set correctly.');
        }
    }

    这样你的程序错误就不会暴漏给用户,并且会记录在php_error.log中,但是即使这样,依然会有一些错误会暴漏出来,这就涉及到CodeIgniter另外的坑。

    原文链接
    h5b.net/codeigniter-php_error-log

  • 相关阅读:
    docker 安装 redis
    docker 安装 fastdfs
    docker 安装 mysql5.7
    docker 安装 nacos
    docker 安装 gitlab-ce
    gitlab记录
    git记录
    ubuntu命令
    java html table 转 excel,给予jdom 和 poi
    自律挑战
  • 原文地址:https://www.cnblogs.com/mitang/p/4093653.html
Copyright © 2011-2022 走看看