如何在CodeIgniter 1.7.2中显示自定义PHP错误消息

时间:2013-05-13 10:09:45

标签: php codeigniter

我想显示自定义错误视图,而不是默认错误页面 生产环境。 我在exception.php中的变化很小。

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[count($x)-2].'/'.end($x);
  }

  if (ob_get_level() > $this->ob_level + 1)
  {
    ob_end_flush();
  }
  //REMOVE IF ISSUE IN APLHA3       
  if($_SERVER['HTTP_HOST'] != 'localhost'){
    ini_set('sendmail_from','info@penpencileraser.com');
    $error_message='Location: '.$filepath;
    $error_message.="\n\n Message: ".$message.' \n\n Line Number :'.$line;
    $error_message.="\n\n Path: ".$_SERVER['PHP_SELF'];
    mail('ramya.p@abc.com','PenPencilEraser Error',$error_message);
    if(APPFOLDER=='frontend'){  
      header("location: ".LINKURL.'errors/common');
      exit;
    }
  }
  //ob_start();
  //include(APPPATH.'errors/error_php'.EXT);
  //$buffer = ob_get_contents();
  //ob_end_clean();
  //echo $buffer;
}

我收到错误

Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.

0 个答案:

没有答案