How to display PHP Errors?
On checking our PHP ini file and the display errors is set and also error reporting is E_ALL. After restarting our Apache web server.
We also entered the above lines on the top of our script and it doesn’t even shown simple parse errors. For example, if we declare the variables with a “$” without the close statement”;”. Then all our scripts shown a blank page on these errors, but Actually we need to see the errors in our browser output
Here is the code which always works for this kind of errors:
however, this code doesn’t make PHP to show parse errors – the only way to show those errors is to modify our php.ini with the below line:
To display all errors :
- Enter the below code in the php script and then run from our browser
2.(a) Make sure that this script has no syntax errors
2.(b) Set display_errors = On in our php.ini
When we include the script from another PHP script then it will display syntax errors in the included script
Here is the another fix:
In this code, the syntax error gives blank output, so use the console to check for syntax errors. The best way to debug PHP code is to use the console.
php -l phpfilename.php
- Create a file called php.ini in the folder where our PHP file resides.
- Inside php.ini add the following code .
Here is the another method of implementation to display the PHP Errors
PHP error_reporting() Function
Note:– When using PHP as an Apache module, we can able to change the configuration settings using directives in Apache configuration files (e.g. httpd.conf) and .htaccess files. Just we need “AllowOverride Options” or “AllowOverride All” privileges to do so.
- Add following values to our .htaccess
Simply enter the below parameters in our main index fileBased on our requirement we can able to choose either all error, all warnings, all notice :
For All Error, Warning and Notice:
For All Error:
For All Warnings:
For All Notice:
- This article provides some of the basic informations on php error , php error log , error reporting php , php error handling , php error display , php error reporting on , php exception handling , php error reporting , php form , php class , php tags , php function , php syntax , php operator , php now , php session , php global , php variable , php substring , php parser , error reporting in php , exception handling in php , error handling in php , error log , errors in php , types of error in php , login php , php source code , error reporting all in php.