yz20sui 发表于 2010-2-26 17:37:31

关闭CI的php notice

用CI的时候,如果一个变量没有值,CI就会提示 Undefined,用PHP的开发的人都知道,定义PHP的变量是不需要初始化任何的值,看这notice真烦人,决定关掉它,开始先搜 A PHP Error was encountered 只在error目录中找到error_php.php,不是想要的结果,这文件只是模板,再搜文件名:error_php,在system/libraies中的Exceptions中发现

    /**
   * Native PHP error handler
   *
   * @accessprivate
   * @param   stringthe error severity
   * @param   stringthe error string
   * @param   stringthe error filepath
   * @param   stringthe error line number
   * @returnstring
   */
    function show_php_error($severity, $message, $filepath, $line)
    {   
      $severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
   
      $filepath = str_replace("\\", "/", $filepath);
         
      // For safety reasons we do not show the full file path
      if (FALSE !== strpos($filepath, '/'))
      {
            $x = explode('/', $filepath);
            $filepath = $x.'/'.end($x);
      }
         
      if (ob_get_level() > $this->ob_level + 1)
      {
            ob_end_flush();
      }
      ob_start();
      include(APPPATH.'errors/error_php'.EXT);
      $buffer = ob_get_contents();
      ob_end_clean();
      echo $buffer;
    }
找到include(APPPATH.'errors/error_php'.EXT); 这行,把它注释掉,就OK了


本文来自黄俊

jimboy 发表于 2010-4-11 10:13:31

这个不错

zycbob 发表于 2010-4-12 13:29:09

初始化变量的确是个好习惯
有助于你的程序健壮 安全

conqweal 发表于 2010-7-9 21:42:08

去改index.php就可以了。。设置错误级别

4ever_CI 发表于 2016-1-23 15:55:26

define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development'); 将index.php里面的development改成production模式就行了。记得重启服务器才行啊。

Hex 发表于 2016-1-25 12:45:15

不建议关掉这个,变量都初始化是一个非常好的编程习惯。
好习惯的养成不容易。
页: [1]
查看完整版本: 关闭CI的php notice