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 p
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.
In your php file just enter this code:
error_reporting(0);
This will report no errors to the user. If you somehow want, then just comment this.
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);
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);
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
http://php.net/manual/en/book.errorfunc.php