Hide PHP errors via .htaccess or PHP code

By default, the PHP display_errors set­ting is set on. You can read more about display_errors at PHP: Error Han­dling and Log­ging Func­tions. There are few impor­tant things that you should know about the error mes­sages that is sent to the browser by display_errors.

Usu­ally these error mes­sages con­tains sen­si­tive infor­ma­tion about the web appli­ca­tion envi­ron­ment that you are run­ning and could lead to unwanted secu­rity threat. It is even stated in the man­ual that it is not rec­om­mended to enable this fea­ture on a pro­duc­tion site.

To dis­able or switch it off (assum­ing that you’re on a shared host­ing which have lim­ited super power), sim­ply add php_flag display_errors off in your .htac­cess file.


If you dont have access to .htaccess file or having trouble editing it, there is a simple solution. Just add

Author: Ashif

Hi, my name is Ashif. I've been earning a living online since 2006 and love to share what I've learned. You can connect with me on Facebook, Twitter, YouTube and Google Plus. Don't forget to subscribe to my blog to keep up with my latest tips and tricks. You can also send questions in my mail.

Leave a Reply

Your email address will not be published. Required fields are marked *