What is PHP error reporting and how to on it to find coding errors
Error reporting is very userful servise to find errors during php development . By default error reporting is disabled in php in most of cases . If error reporting is off the when you run a wrong php code ,nothing happnes on web browser and it seems blank .
Only error reporting is the way to find which type and where is the coding error.
<html> <head> </head> <body> <?php $a = "This is the string" echo $a; ?> </body> </html>
In this example variable $a assigned a string . But a php error is semi colon ( ; ) sign is not used after end on the string “This is the string” . When you save this code and run on web browser ,web browser seems blank and nothing will happen .
In this condition error reporting helps to find errors in php code .
Step to On error_reporting
To on error reporting you need to access php.ini on the root folder . Go to php.ini and open in notepad or any other text editor .
Go down in php.ini in ERROR Logging section and find error_reporting .
Change value of error_reporting = 0 to error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
Save this file and run you upper php code which has error (;) on web browser and see the changes .
Error is displayed “Parse error:
syntax error, unexpected 'echo' (T_ECHO) in C:\xampp\htdocs\php\index.php on line 8"
In this error php installed on localhost so the displayed path is local . If it installed on web host the path is starts from domain name . Find the error and solve it . It is very useful for find errors in large size and complex php codings .
Learm more about error reporting see the following video.