How to disable error output in php 5.6, the pictures processed by some scripts are not shown, when I had enough in .htaccess to do this before:

php_flag log_errors Off php_flag display_errors Off php_flag display_startup_errors Off 

Now it does not help anymore and in php.ini I didn’t quite understand how to turn off error output altogether, but in index.php I registered this error_reporting( E_ERROR ) ;

  • error_reporting(0); , display_errors(false); ? - Alexey Shimansky

2 answers 2

Some directives in php.ini can specify values ​​on the fly. If you have 1 input file (usually php frameworks are so arranged), then you can use the code to control the level of errors through ini_set :

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

Note that during the execution of the script, these directives may change in the same way.

By the way, if you give a picture to a client and an error has occurred in the process, then logically you shouldn’t see the picture. It would be necessary to return the correct HTTP status and document type other than the picture.

Ps. If you are using the framework, then read the manual for it, there should be exactly specified configs for managing error handling.

    In php.ini, you can disable error output by setting the display_errors directive to Off or 0.

     display_errors = Off 

    For the changes to take effect, you must restart the server (apache in the case of php_mod or php-fpm).

    Please note that .htaccess directives work only for the Apache Web server and only if the AllowOverride directive is AllowOverride globally or at the virtual host level.

    • In /etc/apache2/apache2.conf AllowOverride did All, my Web server Apache, also in php.ini set display_errors = Off, restarted, nothing, how to check if error output is disabled? - STC
    • @StirolCraft look in the report of the phpinfo () function, in it specify the path to php.ini, which uses PHP. - cheops
    • Yes, in phpinfo () it is shown that error output is disabled, but today the script again gave an error and now the pictures are not displayed again, this is different, and again, these flags were saved in htaccess before ... - STC