php 为什么 MAMP 不显示错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/14581460/
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
Why MAMP doesn't display errors?
提问by Alex McCabe
OK this is getting very frustrating. MAMP used to display errors but then stopped. I decided to do a fresh install of it as I couldn't figure it out. I check my PHP version, running 5.4.4 and go to that folder and change the php.ini to this:
好的,这变得非常令人沮丧。MAMP 曾经显示错误,但后来停止了。我决定重新安装它,因为我无法弄清楚。我检查我的 PHP 版本,运行 5.4.4 并转到该文件夹并将 php.ini 更改为:
error_reporting  =  E_ALL
display_errors = On
Still no errors showing. I go through all the folders and change all php.ini files, just in case. Nothing. I fix the forced error and dump out phpinfo(), check the error section and display_errors is Off. What the hell. 
仍然没有错误显示。我浏览了所有文件夹并更改了所有 php.ini 文件,以防万一。没有。我修复了强制错误并转储phpinfo(),检查错误部分并且 display_errors 是关闭的。我勒个去。
I place error_reporting(E_ALL); ini_set('display_errors', 'on');at the start of the PHP file and phpinfo()again. Local value is now On, master is still Off. Force a PHP error, and still get Server Error not PHP error. 
我再次放置error_reporting(E_ALL); ini_set('display_errors', 'on');在 PHP 文件的开头phpinfo()。本地值现在是 On,master 仍然是 Off。强制出现 PHP 错误,但仍然得到服务器错误而不是 PHP 错误。
Anybody have any insight? I have a bug somewhere in some code and cannot find it, would love for PHP to just tell me.
有人有任何见解吗?我在某些代码的某处有一个错误并且找不到它,希望 PHP 告诉我。
采纳答案by Alex McCabe
For newer versions of MAMP, the config file is stored in Appliations/MAMP/bin/php/[php version]/conf. 
对于较新版本的 MAMP,配置文件存储在Appliations/MAMP/bin/php/[php version]/conf.
Andrew Nagy pointed me in the right direction with his answer, but it wasn't quite correct for my installation of MAMP. Why they're different, I can't tell, but here we are.
Andrew Nagy 用他的回答为我指明了正确的方向,但对于我安装的 MAMP 来说并不完全正确。为什么它们不同,我不知道,但我们在这里。
If anyone is stuck, the easiest thing to do is to just <?php echo phpinfo(); ?>in the index file of the application and look for the loaded php.inidirectory.
如果有人卡住了,最简单的方法就是<?php echo phpinfo(); ?>在应用程序的索引文件中查找加载的php.ini目录。
回答by pduersteler
MAMP sets up a few different php.inifiles for the server, the client etc. Check in your phpinfo()which php.iniactually is read. Looks like you're editing the wrong one.
MAMP设置了几个不同的php.ini文件服务器,客户端等检查您的phpinfo()其中php.ini实际被读出。看起来你编辑错了。
回答by orhankutlu
There are two php.inifiles on MAMP. You should change both php.inifiles.
php.iniMAMP 上有两个文件。您应该更改这两个php.ini文件。
Applications/MAMP/bin/php/'php version you are using(php5.5.10)'/conf/php.iniApplications/MAMP/conf/php/'php version you are using(php5.5.10)'/conf/php.ini
Applications/MAMP/bin/php/'php version you are using(php5.5.10)'/conf/php.iniApplications/MAMP/conf/php/'php version you are using(php5.5.10)'/conf/php.ini
Then change:
然后改变:
display_errors = Off 
to:
到:
display_errors = On
回答by kenorb
If you're using MAMP PRO, you've to enable Error handling (PHP) in the UI interface which should contain at least two the main options: 'Display startup errors' and set output 'To: Display'.
如果您使用 MAMP PRO,则必须在 UI 界面中启用错误处理 (PHP),该界面应至少包含两个主要选项:“显示启动错误”和设置输出“至:显示”。
Display startup errorsoption is equivalent to display_startup_errors(in PHP) and To: Displayto display_errors.
Display startup errors选项等同于display_startup_errors(在PHP)和To: Display到display_errors。
See below:
见下文:


回答by jojojohn
Change the setting in your php.inifile. The file is located in MAMP > conf > php5 > php.ini
更改php.ini文件中的设置。该文件位于MAMP > conf > php5 > php.ini
Look for display_errors = Offand change to display_errors = On
查找display_errors = Off并更改为display_errors = On
After that you need to restart your Apache and MySQL servers for the change to take effect.
之后,您需要重新启动 Apache 和 MySQL 服务器以使更改生效。
回答by Joe Watkins
MAMP PRO users can visit the PHP tab in UI and make sure Log Errors: to screen is checked: screencast
MAMP PRO 用户可以访问 UI 中的 PHP 选项卡并确保 Log Errors: to screen 被选中:screencast
回答by Andrew Gabriel
If you are using MAMP version 3.2.2 then you only need to change one php.ini file:
如果您使用的是 MAMP 3.2.2 版,那么您只需要更改一个 php.ini 文件:
Mac: Applications/MAMP/conf/'(php7.0.9)'/php.ini
苹果电脑: Applications/MAMP/conf/'(php7.0.9)'/php.ini
Windows: C:\MAMP\conf\PHP Version you use'(php7.0.9)'\php.ini
视窗: C:\MAMP\conf\PHP Version you use'(php7.0.9)'\php.ini
I know this is an old post but MAMP keeps changing their configuration of the files so I hope this helps.
我知道这是一篇旧帖子,但 MAMP 一直在更改他们的文件配置,所以我希望这会有所帮助。
回答by CheddarMonkey
Here's a 2018 update to this problem. First, I'm having the same trouble and found this thread. I used phpinfo() and found yet another location of a php.ini file. Here are the paths (I work on a Mac):
这是此问题的 2018 年更新。首先,我遇到了同样的问题并找到了这个线程。我使用了 phpinfo() 并找到了 php.ini 文件的另一个位置。以下是路径(我在 Mac 上工作):
/Applications/MAMP/bin/php/[php version]/conf/php.ini
/Applications/MAMP/conf/php/[php version]/php.ini
and ...
和 ...
/Library/Application Support/appsolute/MAMP PRO/conf/php.ini
The phpinfo() page lists two sources for the php.ini:
phpinfo() 页面列出了 php.ini 的两个来源:
- Configuration File (php.ini) Path
/Applications/MAMP/bin/php/[php version]/conf - Loaded Configuration File/Library/Application Support/appsolute/MAMP PRO/conf/php.ini
 
- 配置文件(php.ini)路径
/Applications/MAMP/bin/php/[php version]/conf - 加载的配置文件/Library/Application Support/appsolute/MAMP PRO/conf/php.ini
 
I ended up changing all three, adding error_reporting(E_ALL)to some pages, restarting the server (even rebooted the machine) and stillcant get it to display any error messages. 
我最终更改了所有三个,添加error_reporting(E_ALL)到一些页面,重新启动服务器(甚至重新启动机器),但仍然无法让它显示任何错误消息。
i'm not sure where to go from here. Any ideas?
我不知道从这里去哪里。有任何想法吗?
回答by ste
On MAMP 3.2.0 and PHP 7 you'll need to target php.ini-productionand change the value to Production Value = On
在 MAMP 3.2.0 和 PHP 7 上,您需要定位php.ini-production并将值更改为Production Value = On
回答by loveNoHate
Also there is a template saved in MAMP of the php.ini.
Go to File > Edit Template > PHP > Your Version.
还有一个模板保存在php.ini. 去File > Edit Template > PHP > Your Version。

