解析PHP文件时在浏览器中启用错误 [英] Enable errors in browser when parsing PHP-files
问题描述
我最近换成了MacBook,现在使用MAMP-stack进行本地开发.
I recently changed to a MacBook and now use the MAMP-stack for development locally.
在我较早的开发环境中,当我尝试通过Web浏览器访问PHP文件并发生错误时,总能看到有用的错误报告.在默认安装的MAMP中,似乎已禁用此功能,每当我遇到错误时,我都看不到其原因,甚至看不到任何一行通知我发生了错误.
In my earlier development environment I always could see informative error-reports when I tried to access a PHP file through a web-browser and an error occurred. With the default installation of MAMP it seems that this feature is disabled, whenever I hit an error I can't see the cause of it, I can't even see a single line informing me that an error occurred.
直到我开始在调试器中调试代码后,我才能看到错误发生的位置.
Not until I start to debug the code in a debugger I can see where the error occurred.
您知道如何打开错误报告吗?
Any idea how error reporting can be turned on?
我尝试过:
error_reporting(E_ALL);
虽然没有任何作用.
推荐答案
报告到E_ALL
的级别并显示错误on
在include
或require
中每个php文件的顶部包括以下代码例如您的config.php
reporting level to E_ALL
and display errors on
Include the following code at the top of every php file on in an include
or require
such as your config.php
error_reporting(E_ALL);
ini_set('display_errors', 'on');
这篇关于解析PHP文件时在浏览器中启用错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!