How to Remove Warning Messages in PHP
At times while seeing a warning message to the browser, you may want to turn it off. In this snippet, we have chosen two efficient ways that will help you to deal with that problem.
Use error_reporting
The first efficient way is to apply error_reporting.
So, to skip the warning messages, just run the code below:
error_reporting(E_ERROR | E_PARSE);
Use the @Sign
Here is another simple method of removing warning messages with PHP. All you need to do is to put @ in front of the function you intend to run.
Here is an example:
@theFunctionHere();
How error_reporting Works
In PHP, the error_reporting function allows setting the type of error reporting that the programmer intends to apply. It is necessary to simply pass in the kinds of errors to the error_reporting function. The E_PARSE constant informs PHP that the compilation time needs to be reported and shown on the page. The E_ERROR constant informs PHP that the details of the errors need to be reported and illustrated.