Home » Php » apache – php hide ALL errors

apache – php hide ALL errors

Posted by: admin April 23, 2020 Leave a comment


what are the best practises for hiding all php errors? As I don’t want ERRORS to show to the user.

I’ve tried using the .htacess by putting the code php_flag display_errors off in there, but it returns me a 500 error.

Are there any other methods that will hide all errors?

How to&Answers:

to Hide All Errors:

ini_set('display_errors', 0);

to Show All Errors:

ini_set('display_errors', 1);


Per the PHP documentation, put this at the top of your php scripts:

<?php error_reporting(0); ?>


If you do hide your errors, which you should in a live environment, make sure that you are logging any errors somewhere. How to log errors and warnings into a file? Otherwise, things will go wrong and you will have no idea why.


In your php file just enter this code:


This will report no errors to the user. If you somehow want, then just comment this.


Use PHP error handling functions to handle errors. How you do it depends on your needs. This system will intercept all errors and forward it however you want it Or supress it if you ask it to do so



The best way is to build your script in a way it cannot create any errors! When there is something that can create a Notice or an Error there is something wrong with your script and the checking of variables and environment!

If you want to hide them anyway: error_reporting(0);