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告诉我解析错误之类的错误?
2 个解决方案
#1
72
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.
最后,您还可以检查/应用程序/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。
#2
4
You can also access MAMP errors using the Mac "Console" app to read the php_error.log
file.
I find this easiest to access by using spotlight and typing in "error.log".
通过使用spotlight并在“error.log”中输入,我发现这是最容易访问的。
( it won't find it if you type "php_error.log", you must type "error.log" )
(如果输入“php_error”,它就找不到。日志,你必须输入错误。日志”)
It looks like this :
#1
72
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.
最后,您还可以检查/应用程序/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。
#2
4
You can also access MAMP errors using the Mac "Console" app to read the php_error.log
file.
I find this easiest to access by using spotlight and typing in "error.log".
通过使用spotlight并在“error.log”中输入,我发现这是最容易访问的。
( it won't find it if you type "php_error.log", you must type "error.log" )
(如果输入“php_error”,它就找不到。日志,你必须输入错误。日志”)