Disabling PHP or MySQL Errors Display on Webpages

Showing Errors, Warnings, Notice, etc are very dangerous. because users (surfer) can reveal some secrets (like piece of php code, sql query, path of php file) and this may become helpful for the hackers to hack your site.They are required only when debugging.

Managing these error, warning, etc are very easy in php language. you can use the function error_reporting(). it takes following parameters:


By giving any one of the above will enable it. but we want to disable them. so we have to put a '~' symbol (NOT Operation) before them. You can manage multiple items by performing OR operation. The Examples are shown below:

// disable errors error_reporting(~ER_ERROR); // disable notice and warning error_reporting(~(ER_NOTICE | ER_WARNING));

No comments:

Post a Comment

Thank you for commenting. Please keep visiting.