MAMP Config help, display PHP errors

2019-02-09 14:51发布

问题:

I am running the latest version of MAMP on Snow Leopard.

My php.ini file has been configured to display errors. display_errors = on. The phpinfo(); page displays the status of error reporting, it is on. I have restarted my web server several times.

I've searched through Google, and I cannot find any similar problem. Everyone just says to do exactly what I have done, but it is not working. The pages will just remain blank, (with no reporting), if I intentionally place errors.

Any thoughts as to what the problem may be?

回答1:

For any future posters who run into this issue...

I was having the same issue and found that I was making changes to the wrong php.ini files. Run phpinfo and find the path to the active php.ini file to make sure you're editing the correct one.

On my installation of mamp there were multiple instances of the /conf directory with php.ini files. The php.ini files I needed were located in the /bin/php/php[version#]/conf directory and not the MAMP/conf directory.

Exact path to the php.ini file I needed to edit:

Applications/MAMP/bin/php/php5.4.10/conf/php.ini

Change display_errors = Off to display_errors = On



回答2:

In addition to the display_errors directive, which has to be set to On, you might have to configure error_reporting.

For instance, you can use this in your php.ini file :

error_reporting = E_ALL


Another should, useful to test, might be to place this kind of portion of PHP code at the beginning of your script :

error_reporting(E_ALL);
ini_set('display_errors', 'On');

This is useful when you don't have access to php.ini and/or just want to test quickly, without having to restart the webserver.


As a sidenote, when it comes to displaying errors, the Xdebug extension is really great : when it's installed/enabled/configured, instead of just having an error message, you'll get the full stack-trace, which is much more useful ;-)



回答3:

I recently experienced the same problem - in my case I had downloaded a client's Wordpress site from their live server that turned out to have been tampered with by malicious script insertion that was overriding the error reporting in order to escape detection.

A little late to help the OP(!), but perhaps of use to future searchers.



回答4:

There might have a .htaccess file in a directory that overrides the display_errors setting set in php.ini. From your post I assume you didn't explicitly add this but a few frameworks do this by default so might be added that way. Look for a line like this in your .htaccess file:

php_value display_errors 0

and change the value to 1.



回答5:

If you have several php sdks with several versions, first make it sure you are editing correct php.ini file. If you were right add this two lines at the beginning of the code.

error_reporting(E_ALL);
ini_set('display_errors', 'On'); // or ini_set('display_errors', 1);


回答6:

Here's a twist to the same answer. I had the same issues, just copied and pasted the ini path from the php info page and still same problems...

turns out I made a syntax mistake when I edited my 'error_reporting' block in the php.ini.

I had E_NOTICE rather than ~E_NOTICE.

:(

So mistakes can happen in the php.ini if you were editing it and totally forgot you edited something.



标签: php apache mamp