提问人:jaydisc 提问时间:9/26/2013 最后编辑:jaydisc 更新时间:9/30/2013 访问量:490
CodeIgniter 错误报告 1.7.x 和 2.x 之间的差异
CodeIgniter Error Reporting Difference between 1.7.x and 2.x
问:
我有两个相同的 Debian Squeeze 服务器运行 php 5.3.3-7+squeeze17,一个运行 1.7.x,另一个运行 2.1.4。
在 1.7 安装中,当我调用调用未定义模型方法的控制器方法时,页面输出:
Fatal error: Call to undefined method Example_Model::get_series_and_products() in /opt/git/online_live/application/controllers/members.php on line 2549
但是,在 2.1.4 上根本没有输出。 在未定义的函数输出文本之前插入语句,但之后的语句不插入。echo
这两个站点在其 VirtualHost 配置中都将 php error_reporting设置为 -1,这似乎覆盖了开发的config.php定义的 ENVIRONMENT 设置,该设置将 error_reporting 设置为 E_ALL。
以下是我用于输出的一些额外代码:
echo ini_get('error_reporting');
echo '<br>';
echo phpversion();
两者的输出相同:
-1
5.3.3-7+squeeze17
因此,似乎没有其他任何事情胜过我的error_reporting。
在 2.1.4 的 application/config/config.php 中(未显示错误):
$config['log_threshold'] = 4; // All Messages
在 1.7 中(显示错误的地方):
$config['log_threshold'] = 0;
但我认为该设置是针对 CI 保留的文件系统日志,而不是内联错误。
phpInfo() 在两台主机上反映相同的error_log值:
error_log: no value no value
error_reporting: -1 22527
是什么导致了这种差异?
答:
编辑:如果您的设置是使用 或 设置的,则此设置不适用。感谢 jaydisc 启发了我这个事实。答案就在指令中,它控制着错误的显示。php_admin_value
php_admin_flag
display_error
但是,我将帖子的其余部分留在这里,因为根据问题标题,如果不是设置,这将是一个可能的答案。php_admin_value
1.7.x 和 2.x 之间的错误报告差异
无论您的设置如何,Codeigniter 都会在 .http://php.net/manual/en/function.error-reporting.phperror_reporting
index.php
The error_reporting() function sets the error_reporting directive at runtime. PHP has many levels of errors, using this function sets that level for the duration (runtime) of your script.
这属于一个函数系列:http://php.net/manual/en/function.ini-set.php,它们在脚本的持续时间内覆盖 php 指令,包括php_admin_value。error_reporting
ini_set
对于 1.7.x,(在此处查看旧版本 http://ellislab.com/codeigniter/user-guide/installation/downloads.html),
其中的第一行代码是index.php
error_reporting(E_ALL);
,无论如何都会启用错误(除非稍后通过代码更改设置)。
对于 2.1.4,(https://github.com/EllisLab/CodeIgniter/blob/2.1.4/index.php) 它取决于常量:ENVIRONMENT
/*
*---------------------------------------------------------------
* ERROR REPORTING
*---------------------------------------------------------------
*
* Different environments will require different levels of error reporting.
* By default development will show errors but testing and live will hide them.
*/
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.');
}
}
评论
error_reporting()
display_error
Any directive type set with php_admin_value can **not** be overridden by .htaccess or ini_set().
评论
phpinfo()