我有错误致命错误:类“是CI_Controller”在.... \没有找到核心\ CodeIgniter.php上线233扩展异常CI中
我创建了一个称为应用程序/核心/ My_Exception My_Exceptions类。 php 基本上,我想在用户从我的网站获取错误时收到电子邮件。
<?php
class My_Exceptions extends CI_Exceptions{
var $CI="";
function __construct(){
parent::__construct();
$this->CI =& get_instance();
}
function show_404($page = '', $log_error = TRUE)
{
$heading = "404 Page My Not Found";
$message = "The page you requested was not found.";
// By default we log this, but allow a dev to skip it
if ($log_error)
{
log_message('error', '404 Page Not Found --> '.$page);
}
//Email to Developer
$this->CI->load->library('email');
$uri = $this->CI->uri->uri_string();
$this->CI->email->from('[email protected]', 'APP Error');
$this->CI->email->to('[email protected]');
$this->CI->email->subject('APP Error [severity: '.$severity.']');
$this->CI->email->message("Page not Found. From URL: ".$uri);
$this->CI->email->send();
echo $this->show_error($heading, $message, 'error_404', 404);
exit;
}
}
请帮忙!!!
这似乎很疯狂得到一个电子邮件*获取生成每个* 404,发送电子邮件或手动检查每天的日志更有意义(我能理解不想创建cron作业)。本地'mail()'应该没问题,当你只是给自己发送电子邮件时,这没什么大不了的。 – 2012-07-24 03:25:00
我认为他是在其他错误之后,而不仅仅是404的 – Laurence 2012-07-24 04:01:43
OP的代码被写入'show_404'函数,但你可能是对的。在这种情况下,我会说,为每个错误发送一封单独的电子邮件会更加疯狂,因为会有更多。除非你真的希望你的收件箱像疯了一样疯狂......单页加载可以生成*吨* 404(例如缺少图片)。 – 2012-07-24 04:04:34