php.ini hide notices and warnings

stargateatlantis
stargateatlantis used Ask the Experts™
on
In my php.ini I am trying to show errors only but not warnings.  Her is some settings I have below.

display_errors = On

and

error_reporting = E_ALL & ~E_NOTICE & ~E_WARNING

But notices and warnings still show up
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2011
Top Expert 2016

Commented:
Those constants may or may not work.  Check this link.
http://php.net/manual/en/configuration.changes.php

See also: http://php.net/manual/en/errorfunc.configuration.php#ini.error-reporting
What you might want to do is log errors, warnings and notices, but not show any of them to clients.  Maybe something like this:

error_reporting = 32767
display_errors = Off
log_errors = On
log_errors_max_len = 1024
error_log = error_log

If you want a script that can find the error logs, just post back and I'll put it here.

Author

Commented:
So this will disable show warnings
Most Valuable Expert 2011
Top Expert 2016
Commented:
The php.ini settings I posted will disable browser display of all PHP messages related to Notice, Warning, and Error.  You will still be able to find the information in the error_log file, but it will not "tip your hand" to potential hackers by exposing the PHP issues.

You can also use the @ prepended to the name of a function to suppress the messages from a specific function call, but I do not recommend that - it can cause silent failures and is considered an antipractice.

If you really want to turn off Notice and Warning, but leave Error available for display, you can set this:

error_reporting = 32757
display_errors = On

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial