A PHP application produces many levels of errors during the runtime of the script . So in this article, we will learn how to display all the errors and warning messages.
The quickest way to display all php errors and warnings is to add these lines to your PHP code file:
ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
The ini_set function will try to override the configuration found in your php.ini file. If in the php.ini file display_error is turned off it will turn that on in the code. It also set display_startup_errors to true to show the error message. error_reporting() is a native PHP function that is used to display the errors. By setting it true it displays the error that occurs in the code.
But there is an again question arises what is E_ALL? The answer is simple PHP code produces different levels of errors. So let's learn what are those types of errors occurs in a PHP code.
Unfortunately, the above code we have composed won't almost certainly show parse errors, for example, missing semicolons or missing wavy supports. For this situation, the php.ini setup must be altered.
display_errors = on
The display_errors order must be set to "on" in the php.ini document. This will show every one of the errors including syntax or parse mistakes that can't be shown by simply calling the ini_set work in the PHP code.So in the above way, we can display errors in our php application.