当我在 PHP 中开发我的 REST API 时,我正在使用 application/json
输出,所以当我在浏览器中测试时出现错误时,它们看起来像这样:
When I'm developing my REST API in PHP I'm working with application/json
output, so when I get errors while testing in the browser they look like this:
<b>Fatal error</b>: Uncaught exception 'Exception' with message 'PDO caught an error:
array(3) {
[0]=>
string(5) "42000"
[1]=>
int(1065)
[2]=>
string(15) "Query was empty"
}
当我得到大量的堆栈跟踪和其他东西时,情况会变得更糟.那么有没有我可以设置的标志告诉 PHP 我希望我的错误不转义并以原始文本形式显示?
And it gets worse when I get large stack traces and stuff. So is there a flag I can set telling PHP that I want my errors unescaped and in raw text?
这是一个 php.ini
设置,名为 html_errors
.
It is a php.ini
setting called html_errors
.
这篇关于如何告诉 PHP 将异常转储为原始文本而不是 HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!