Wordpress & PHP Warnings

What issue or error are you experiencing?

Using any PHP 8.0.30 and beyond in LocalWP will result in showing PHP warning messages. Based on the research I have done, adding the following lines to the wp-config.php file resolves this:

ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);

This works as all errors and warnings are hidden, but what I would like is SHOW errors, HIDE warnings - I feel like a developer that is the most useful functionality. Some stupid warning about the class-walker-nav-menu.php file I don’t care about. But if I made a mistake developing my theme or plugin which generates an error, I certainly would like to know about it.

Summary - how do you show PHP errors but hide PHP warnings?

Thanks for your help!


What steps can be taken to replicate the issue? Feel free to include screenshots, videos, etc

I have done some research and I think the changing this line ini_set('error_reporting', E_ALL ); from E_ALL to E_NOTICE or even E_ERROR should work, but it doesn’t.

The issue seems to be from the previous line being configured ini_set('display_errors','Off');. When I comment this out, irrespective of what I see error_reporting to I always seem to get the all warnings and errors.

If anyone could help that would be fantastic, I am assuming this should be a very common requirement from a dev point of view - i.e. not necessarily want to see warnings but do want to see errors.


System Details

  • Local Version: 7.2.1+6433

  • Operating System (OS) and OS version: MacOS Sonoma 14.0


Local Logs

Attach your Local Logs here (Help Doc - Retrieving Local’s Log)

None this is on screen warnings and errors.


Security Reminder
Local does a pretty good job of scrubbing private info from the logs and the errors it produces, however there’s always the possibility that something private can come through. Because these are public forums, always review the screenshots you are sharing to make sure there isn’t private info like passwords being displayed.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.