Enable errors in browser when parsing PHP-files
Asked Answered
J

4

16

I recently changed to a MacBook and now use the MAMP-stack for development locally.

In my earlier development environment I always could see informative error-reports when I tried to access a PHP file through a web-browser and an error occurred. With the default installation of MAMP it seems that this feature is disabled, whenever I hit an error I can't see the cause of it, I can't even see a single line informing me that an error occurred.

Not until I start to debug the code in a debugger I can see where the error occurred.

Any idea how error reporting can be turned on?

I tried:

error_reporting(E_ALL);

No effect at all though.

Julian answered 23/5, 2011 at 10:14 Comment(3)
You need to set this in the php.ini to have an effect for parsing errors.Wolfson
have you checked the error reporting level in the php.ini?Bengal
If you checked the php.ini, did you look at the right one? Be default there are at least two different php.inis (one for cli and one for apache). Additional some IDEs use an own one.Stricklan
C
32

reporting level to E_ALL and display errors on Include the following code at the top of every php file on in an include or require such as your config.php

error_reporting(E_ALL);
ini_set('display_errors', 'on');
Cara answered 23/5, 2011 at 10:32 Comment(1)
This solved the issue. A more permanent solution was to edit the php.ini file and change the configuration to the following: error_reporting = E_ALL display_errors = OnJulian
R
4

Try ini_set('display_errors', 'on');

You'll also want to check a phpinfo(), to see if the ini_sets are doing anything.

Reahard answered 23/5, 2011 at 10:27 Comment(0)
B
2

Or change "display_errors = Off" to "display_errors = On" in /Applications/MAMP/bin/php/php5.4.4/conf/php.ini

Bestrew answered 23/9, 2012 at 19:2 Comment(0)
B
0

Navigate to MAMP settings (eg localhost:8889/MAMP)

Click PHP Tab

Find Log errors: setting

Tick to screen

Click Save

Businesslike answered 3/2, 2018 at 2:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.