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?
To turn off or disable error reporting in PHP, set the value to zero.
In the current file, search for the line of code error_reporting. There will be a line of Default Value: E_ALL as shown below: Replace this line of code with Default Value: E_ALL & ~E_NOTICE. It will display all the errors except for the notices.
Quickly Show All PHP Errors The quickest way to display all php errors and warnings is to add these lines to your PHP code file: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
to Hide All Errors:
error_reporting(0); ini_set('display_errors', 0);
to Show All Errors:
error_reporting(E_ALL); ini_set('display_errors', 1);
Per the PHP documentation, put this at the top of your php scripts:
<?php error_reporting(0); ?>
http://php.net/manual/en/function.error-reporting.php
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With