解析 PHP 文件时在浏览器中启用错误
我最近换了一台 MacBook,现在使用 MAMP 堆栈进行本地开发。
在我早期的开发环境中,当我尝试通过网络浏览器访问 PHP 文件并发生错误时,我总是可以看到信息丰富的错误报告。在 MAMP 的默认安装中,似乎此功能被禁用,每当我遇到错误时,我都看不到它的原因,我什至看不到任何一行通知我发生了错误。
直到我开始在调试器中调试代码,我才能看到错误发生的位置。
知道如何打开错误报告吗?
我试过了:
error_reporting(E_ALL);
不过一点效果都没有。
I recently changed to a MacBook and now use the MAMP-stack for development locally.
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?
I tried:
error_reporting(E_ALL);
No effect at all though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
向
E_ALL
报告级别并显示错误on
在include
或require< 中每个 php 文件的顶部包含以下代码/code> 例如您的
config.php
reporting level to
E_ALL
and display errorson
Include the following code at the top of every php file on in aninclude
orrequire
such as yourconfig.php
尝试
ini_set('display_errors', 'on');
您还需要检查
phpinfo()
,看看 ini_sets 是否正在执行任何操作。Try
ini_set('display_errors', 'on');
You'll also want to check a
phpinfo()
, to see if the ini_sets are doing anything.或者将 /Applications/MAMP/bin/php/php5.4.4/conf/php.ini 中的
"display_errors = Off"
更改为"display_errors = On"
Or change
"display_errors = Off"
to"display_errors = On"
in /Applications/MAMP/bin/php/php5.4.4/conf/php.ini导航到 MAMP 设置(例如
localhost:8889/MAMP
)单击
PHP
选项卡查找
日志错误:
设置勾选
to screen
>单击
保存
Navigate to MAMP settings (eg
localhost:8889/MAMP
)Click
PHP
TabFind
Log errors:
settingTick
to screen
Click
Save