How To

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 the 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 the PHP page to remove errors, warnings, and notices from that page.

error_reporting(0);

Method 2: Remove on the Whole Project .HTACCESS File

This method helps remove errors, warnings, and notices from the whole PHP project. We need to insert the below code into our projects.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 the 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 the display_errors flag.

display_errors = Off

Read Also: How to Echo New Line in PHP

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 🙂

Nachiket Panchal

Founder & Administrator of `errorsea` Having interest in Programming & Technology.

Recent Posts

5 Important Things To Know About WordPress Before You Use It

There is a reason big-name companies like CNN use WordPress. WordPress is a popular content…

3 years ago

How to Install MySQL on Your PC in 3 Easy Steps

In this tutorial, I'm going to show you how to install MySQL on your computer.…

5 years ago

Download and Install Turbo C++ for Windows 10 (Full Installation Guide)

Download Turbo C++ for windows 10 in just 7 Mb and run your first C++…

5 years ago

PHP .HTACCESS Redirects

We can redirect any webpage to any other or redirect the whole domain or website…

5 years ago

PHP Redirect Pages

There are lots of methods to redirect pages, like refresh-redirect from META tag, redirect from…

5 years ago

PHP Include & Required

Include files in PHP are used in appending various global or config files. We can…

5 years ago