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

  • 相关阅读:
    Best Time to Buy and Sell Stock
    Permutations II
    数组中最大和的子数组
    基于Socket.IO的Client封装
    Java中的ThreadLocal功能演示
    基于WebSocket的client封装
    Socket接口开发和测试实践
    自动化测试用例的原子性
    [CF1477C] Nezzar and Nice Beatmap
    [CF1477B] Nezzar and Binary String
  • 原文地址:https://www.cnblogs.com/mitang/p/4093653.html
Copyright © 2011-2022 走看看