3

So I'm running MAMP on my Mac since I was unable to change my htdocs location to a directory on a local server (no problem to use that local server with MAMP though)

Somehow, php error reporting is disabled for me. I used phpinfo(); to find the right ini file (which is located at "Applications ▸ MAMP ▸ bin ▸ php ▸ php5.6.10 ▸ conf" in my case) and changed display_errors from "off" to "on" (without the " " of course)

error_reporting is set to E_ALL

However, when I now run phpinfo(); again, Display errors is still turned off.

I have also tried to override those values in the php code without success.

Apparently MAMP overrides the modified php.ini everytime it starts. Source: https://stackoverflow.com/a/16154605/2667307

Community
  • 1
  • 1
Noniq
  • 369
  • 1
  • 5
  • 13

3 Answers3

4

Why you are not creating a script with <?php phpinfo() ?> ? by running in browser you'll see Loaded Configuration File This tells you which php.ini file PHP is using like for me it's at /etc/php5/apache2/php.ini

Review below screenshot.

though,

You can try to override it by doing error_reporting(E_ALL);

// Report all PHP errors
error_reporting(E_ALL);

and

if (!ini_get('display_errors')) {
    ini_set('display_errors', '1');
}
Shashank Shah
  • 2,077
  • 4
  • 22
  • 46
0

I used to have the same issue. Then i found in MAMP if you go to "File -> Edit Template -> PHP -> ". Edit the file there and restart MAMP.

The issue is that the files reside in two or three places in MAMP on Mac.

isnisn
  • 254
  • 1
  • 7
  • Does this require the PRO version? I only have the standard one. I am 100% sure I edited exactly the php.ini file that I was shown by phpinfo(); how can I have edited the wrong file then? – Noniq Feb 26 '16 at 12:37
  • Then i will edit my answer. Its still good to know. Do a "find / -name php.ini" in terminal. It will find all your php.ini in your system. – isnisn Feb 26 '16 at 12:45
  • Thank you @isnisn, I am new to MacOS – Noniq Feb 26 '16 at 13:17
0

Changing

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

in your PHP script to

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

will display the errors properly in your browser. As the first alternative should send the errors to your log file.

You can check the manual here: http://php.net/manual/de/function.error-reporting.php

leopold
  • 1,971
  • 1
  • 19
  • 22