如何在代码输出中显示 PHP 错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6587515/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to display PHP errors in code output?
提问by John Tor
When executing a PHP page through browser , we will just get the output but not the errors in code.
当通过浏览器执行 PHP 页面时,我们只会得到输出而不是代码中的错误。
how can i view the errors occurred by the code in the backend??
我如何查看后端代码发生的错误?
I am using the following in the code for error reporting..
我在错误报告的代码中使用以下内容..
error_reporting(E_ALL | E_ALL);
回答by Dejan Marjanovic
ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_NOTICE);
回答by Michael Irigoyen
Try -1
. From the documentation, "Passing in the value -1 will show every possible error, even when new levels and constants are added in future PHP versions."
试试-1
。从文档中,“传入值 -1 将显示所有可能的错误,即使在未来的 PHP 版本中添加了新的级别和常量。”
// Report all PHP errors
error_reporting(-1);
If that doesn't work, try to do an ini_set
:
如果这不起作用,请尝试执行以下操作ini_set
:
// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
回答by Amir Rezazadeh
Inside your php.ini, set the display_errors
to On
:
在你的php.ini 中,设置display_errors
为On
:
display_errors = On
Then restart your web server.
然后重新启动您的 Web 服务器。