How to Remove On-Page Errors in PHP

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.

  1. Remove on Specific PHP Page
  2. Remove on Whole Project .HTACCESS File
  3. 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.

error_reporting(0);

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

Conclusion

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 🙂

Leave a Reply

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

Read previous post:
Default Value in select menu in HTML Using JavaScript
How to Set Default Value in Dropdownlist in HTML Using JavaScript

Selecting a default value in a dropdown list is very easy. Here we are going to learn how to select...

Close