我怎样才能让 MAMP 告诉我 php 代码出了什么问题?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8641383/
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
How can I get MAMP to tell me what went wrong with php code?
提问by Ulmer
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?
每当我的 php 代码出错时,MAMP 只会返回 500 错误。无论如何,我可以让 MAMP 告诉我解析错误之类的错误吗?
回答by Yes Barry
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:
正如您报告的那样,您必须display_errors
设置为on
。这可以通过更改 conf 文件或使用 .htaccess 来完成,如下所示:
<IfModule mod_php5.c>
php_flag display_errors on
</IfModule>
Additionally, you can do this with ini_set()
like so:
此外,您可以ini_set()
像这样执行此操作:
ini_set('display_errors', 1);
One last thing, you can also check /Applications/MAMP/logs
which has three different error log files.
最后一件事,您还可以检查/Applications/MAMP/logs
哪个具有三个不同的错误日志文件。
Try opening terminal and run this command:
尝试打开终端并运行以下命令:
tail -f /Applications/MAMP/logs/php_error.log
When you want to stop "following" (the -f
switch) the log file, just type control+C.
当您想停止“跟踪”(-f
开关)日志文件时,只需键入control+C。
回答by kris
You can also access MAMPerrors using the Mac "Console" appto read the php_error.log
file.
您还可以使用 Mac “控制台”应用程序访问MAMP错误以读取文件。php_error.log
I find this easiest to access by using spotlight and typing in "error.log".
我发现通过使用聚光灯并输入“error.log”最容易访问。
( it won't find it if you type "php_error.log", you must type "error.log" )
(如果你输入“php_error.log”它不会找到它,你必须输入“error.log”)