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.
Index
There are three methods to remove on-page errors in PHP.
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); 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 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
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 🙂
There is a reason big-name companies like CNN use WordPress. WordPress is a popular content…
In this tutorial, I'm going to show you how to install MySQL on your computer.…
Download Turbo C++ for windows 10 in just 7 Mb and run your first C++…
We can redirect any webpage to any other or redirect the whole domain or website…
There are lots of methods to redirect pages, like refresh-redirect from META tag, redirect from…
Include files in PHP are used in appending various global or config files. We can…