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

  • 相关阅读:
    C# 后台调用webApi
    WebApi传参详解
    网络爬虫字体解密
    单元测试的简单实用
    JQuery中$.ajax()方法参数详解
    vscode HTML标签换行问题
    C#基础之Assembly 当前项目的程序集GetAssemblies
    RedisHelper
    vue setTimeout 和 this.$nextTick,BMap api
    excel 导出 OpenXml
  • 原文地址:https://www.cnblogs.com/mitang/p/4093653.html
Copyright © 2011-2022 走看看