繁体   English   中英

PHP中的飞行错误报告

[英]On the fly error reporting in PHP

当我们的网站曾经在安装了PHP的IIS主机上时,我将错误报告设置为E_NONE并且能够通过使用以下方式临时打开它:

ini_set('display_errors', 1);

现在我们在Linux / Apache托管上,该命令似乎不再有效。 我试图故意向服务器发送错误的命令,我没有报告错误。

我究竟做错了什么? 有没有其他方法可以暂时打开错误报告,而无需每次都编辑php.ini?

您可以使用以下行将错误报告更改为E_ALL

error_reporting(E_ALL);

尝试将其添加到文件中。

打开所有错误的最佳方法是:

error_reporting( -1 );

这比E_ALL更好,因为E_ALL实际上并不意味着所有PHP版本中的所有错误(它只在最近的版本中发生)。 -1是确保在所有情况下都启用的唯一方法。

我只需要在我的一个脚本中执行此操作。 DOMDocument警告正在查杀我的日志。 那么,这就是你做的:

// First, grab a copy of the current error_reporting level
// while setting the new level, I set it to zero because I wanted
// it off - but you could easily turn it on here
$erlevel = error_reporting(0);
// Then, do stuff that generates errors/warnings
// Finally, set the reporting level to it's previous value
error_reporting($erlevel);

暂无
暂无

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

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