我如何让MAMP告诉我php代码出了什么问题? [英] How can I get MAMP to tell me what went wrong with php code?
问题描述
每当我的php代码有错误时,MAMP只会返回500错误.无论如何,我可以让MAMP告诉我什么地方出了问题,例如解析错误和内容吗?
Whenever I have an error in my php code, MAMP just returns a 500 error. Is there anyway I can get MAMP to tell me what went wrong like parsing errors and stuff?
推荐答案
正如您所报告的,您必须将display_errors
设置为on
.可以通过更改conf文件或使用.htaccess这样的方式来完成此操作:
Just as you reported, you must have display_errors
set to on
. This can be done either by changing the conf file or by using .htaccess like so:
<IfModule mod_php5.c>
php_flag display_errors on
</IfModule>
此外,您可以像这样使用ini_set()
进行此操作:
Additionally, you can do this with ini_set()
like so:
ini_set('display_errors', 1);
最后一件事,您还可以检查具有三个不同错误日志文件的/Applications/MAMP/logs
.
One last thing, you can also check /Applications/MAMP/logs
which has three different error log files.
尝试打开终端并运行以下命令:
Try opening terminal and run this command:
tail -f /Applications/MAMP/logs/php_error.log
要停止跟随"(-f
开关)日志文件时,只需键入 control + C .
When you want to stop "following" (the -f
switch) the log file, just type control+C.
这篇关于我如何让MAMP告诉我php代码出了什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!