On-page errors, warnings, and notices are default in PHP for convenient debugging. However, while deploying on production it is not a good practice to show on-page errors.
On-page errors may provide loopholes of our website to hackers. Even more, it can break our website’s front end design.
Here we are going to learn how to disable on-page errors, warnings, and notices in PHP.
PHP Remove On-Page Errors, Warnings, Notices
There are three methods to remove on-page errors in PHP.
- Remove on Specific PHP Page
- Remove on Whole Project .HTACCESS File
- Remove on HOST via php.ini File
Method 1: Remove on Specific PHP Page
This method is to disable errors on a specific page in our PHP website. Insert below PHP code at the top of PHP page to remove errors, warnings, and notices from that page.
Method 2: Remove on Whole Project .HTACCESS File
This method is helpful to remove errors, warnings, and notices from the whole PHP project. We need to just inset below code to our project’s .HTACCESS file.
php_flag display_errors = Off
Method 3: Remove on HOST via php.ini File
This method is used to apply when we have to remove errors, warnings, and notices from whole host machine. Which will affect all projects running on that host server.
Just go to the php.ini file in your host machine and turn off display_errors flag.
display_errors = Off
Here we have discussed every method to remove or disable on-page errors, warnings, and notices in PHP projects.
I hope this post will help you to resolve your problem.
Happy Coding 🙂