繁体   English   中英

Ubuntu 14.04上的php5.6没有使用默认错误处理程序显示错误

[英]php5.6 on Ubuntu 14.04 is not showing errors with default error handler

我最近在Ubuntu 14.04上安装了apache2和php5.6。在apache和cli的php.ini中,我用正确的配置设置了所有参数(我认为):

error_reporting = E_ALL
display_errors = On
display_startup_errors = On
log_errors = On
track_errors = On
error_log = "/var/log/php_errors.log"

error_log指向的文件是可写的。

而且我可能会在命令链接或Web浏览器中显示错误。

我花了几个小时在网上搜索,唯一想到的是我设法手动设置了在一个脚本中处理的错误,方法是:

set_error_handler("var_dump");

更改错误处理程序时,将打印一些信息(我强制执行的mysql错误):

$ php informe_presupuestos.php
/var/www/buv/lib/sqlquery.class.php:88:
int(2)
/var/www/buv/lib/sqlquery.class.php:88:
string(72) "mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given"
/var/www/buv/lib/sqlquery.class.php:88:
string(66) "/var/www/buv/lib/sqlquery.class.php"
/var/www/buv/lib/sqlquery.class.php:88:
int(88)
/var/www/buv/lib/sqlquery.class.php:88:
array(1) {
  'result_id' =>
  string(4) "pres"
}

我也尝试在脚本开始时使用restore_error_handler(),但不起作用。

关于如何启用错误显示的任何想法?

很少有线您拥有的东西,因为通常它应该可以工作,但是我现在不知道您的.php是什么,所以请尝试以下操作:

<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
register_shutdown_function(function(){while(ob_get_level()>0)ob_end_flush();});

顺便说一句,在测试脚本时/var/log/php_errors.log的内容是什么。

来自http://php.net/manual/en/function.set-error-handler.php的注释:

用户定义的函数无法处理以下错误类型:E_ERROR,E_PARSE,E_CORE_ERROR,E_CORE_WARNING,E_COMPILE_ERROR,E_COMPILE_WARNING,以及在调用set_error_handler()的文件中引发的大多数E_STRICT。

因此,如果您现在不现实,最好使用默认错误处理程序。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM