5

So what's going on is I tried

ini_set('display_errors', 'Off');
error_reporting(0);

Right below <?php, but this didn't seem to stop displaying them. So I went to the php.ini and went to display_errors and saw that it was set to Off. But it still showed.

So I went and did phpinfo() and display_errors along with display_startup_errors are both off. Also html_errors is off. I'm not sure if this will help, but it says error_reporting is set to -10241. Any ideas?

18
  • 7
    Are you running your own code, or some framework code? And is the php.ini listed in phpinfo() the same one you examined? Commented Jul 30, 2014 at 2:00
  • 2
    After modifying the Php.ini did you restart apache? Commented Jul 30, 2014 at 2:01
  • 1
    Firstly, what code is causing these said errors? Commented Jul 30, 2014 at 2:08
  • 3
    These can be easily solved with an isset condition. Do not hide your errors. Resolve them. Commented Jul 30, 2014 at 2:19
  • 2
    I'd personally choose a package which handled errors over turning reporting off. Imho it's extremely lazy and is not a fix, as turning off errors will stop one seeing more important errors. Or even if one logs errors with no display, error logs would be flooded with unhandled notices and will make said error log a large file very quickly (as every refresh will input duplicate error messages with different time stamps) Commented Jul 30, 2014 at 2:38

3 Answers 3

3

Do not change the value of error reporting to solve the issue. If display_errors is off, errors are not display independently of the error_reporting setting. This way you will not display errors but you can still log them.

The following should work:

ini_set('display_errors', 'Off');

If it doesn't work it could be that your server configuration does not allow you to change settings from PHP scripts. ini_set() returns FALSE on failure. So first of all you should check what value that call is returning. Make sure that ini_set is not listed among disabled PHP functions (disable_functions in php.ini).

If you are asking yourself why errors are still being displayed even if in php.ini the display_errors is Off, you can check the actual value of display_errors during the script execution:

ini_get('display_errors')

Pemember that PHP settings could be changed also in Apache host configuration and in .htaccess files. So check if you have an htacces that enables display_errors. Something like this:

php_flag display_errors on
Sign up to request clarification or add additional context in comments.

Comments

1

Try to use:

ini_set('display_errors', 0);
ini_set('display_errors', false);

Comments

1

You don't describe what the errors are, so it's possible that your web server (Apache, nginx, etc) are what's throwing the error and not PHP.

If it is PHP, ensure that you're editing the correct php.ini as identified in your phpinfo.php. Remember that if you edit the php.ini, you will need to restart your PHP process (for example, on some *nix systems: service php-fpm restart. Your exact command may vary.)

If it's off in your php.ini, my guess is that it's being overridden somewhere else -- either later in the script ('grep "ini_set" /path/to/project/*.php' will find it). Also, the PHP Manual states that if the script has fatal errors, it doesn't apply if there are fatal errors:

Although display_errors may be set at runtime (with ini_set()), it won't have any effect if the script has fatal errors. This is because the desired runtime action does not get executed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.