解析 PHP 文件时在浏览器中启用错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6095798/
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
Enable errors in browser when parsing PHP-files
提问by aksamit
I recently changed to a MacBook and now use the MAMP-stack for development locally.
我最近换成了 MacBook,现在使用 MAMP-stack 进行本地开发。
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.
在我早期的开发环境中,当我尝试通过 Web 浏览器访问 PHP 文件并发生错误时,我总是可以看到信息丰富的错误报告。MAMP 的默认安装似乎禁用了此功能,每当我遇到错误时,我都看不到它的原因,我什至看不到一行通知我发生了错误。
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?
知道如何打开错误报告吗?
I tried:
我试过:
error_reporting(E_ALL);
No effect at all though.
不过完全没有效果。
回答by afarazit
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
报告水平E_ALL
和显示误差on
在包含在每个PHP文件的顶部下面的代码上include
或require
如您config.php
error_reporting(E_ALL);
ini_set('display_errors', 'on');
回答by Dunhamzzz
Try ini_set('display_errors', 'on');
尝试 ini_set('display_errors', 'on');
You'll also want to check a phpinfo()
, to see if the ini_sets are doing anything.
您还需要检查phpinfo()
, 以查看 ini_sets 是否在执行任何操作。
回答by mvod
Or change "display_errors = Off"
to "display_errors = On"
in /Applications/MAMP/bin/php/php5.4.4/conf/php.ini
或更改"display_errors = Off"
为"display_errors = On"
/Applications/MAMP/bin/php/php5.4.4/conf/php.ini
回答by sq2
Navigate to MAMP settings (eg localhost:8889/MAMP
)
导航到 MAMP 设置(例如localhost:8889/MAMP
)
Click PHP
Tab
单击PHP
选项卡
Find Log errors:
setting
查找Log errors:
设置
Tick to screen
打钩 to screen
Click Save
点击 Save