To begin with lets see what each one is all about
Notices – The names says it all, they really don’t mean anything serious just a notice for you to consider. Example undefined string.
Warnings – You ought to give a consideration to these. A warning can occur due to different reasons like trying to refer a file in your script when you don’t have one in that name.
Fatal Errors - Something to deal with immediately.
Parse Error -
When you put in something like this u get this error
<? <html> </html> ?>The php parser will not identify HTML tags and you get a parse error.
Difference Between Error and Warning
The difference between Warning and Error is a warning will not terminate the script were as a fatal error would.
You can set the “error reporting” level in you “php.ini” file
; - Show all errors, except for notices
;error_reporting = E_ALL & ~E_NOTICE
; - Show only errors
;error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
; - Show all errors except for notices
error_reporting = E_ALL & ~E_NOTICE
Now you feel that you don’t have rights to change the ini file, well you can tackle them in your script, now lets see how it’s done.
List of errors that occur
Error Type What do they mean?
E_ERROR --------- Fatal runtime error
E_WARNING --------- Non-fatal runtime error
E_PARSE --------- Runtime parse error
E_NOTICE --------- Non-fatal runtime notice
E_CORE_ERROR --------- Fatal startup error
E_CORE_WARNING --------- Non-fatal startup error
E_COMPILE_ERROR --------- Fatal compile-time error
E_COMPILE_WARNING --------- Non-fatal compile-time error
E_USER_ERROR --------- User-triggered fatal error
E_USER_WARNING --------- User-triggered non-fatal error
E_USER_NOTICE --------- User-triggered notice
E_ALL --------- All of the above
To avoid errors in PHP script use the error_reporting function
<? error_reporting(0); ?>
This will not report any error. Don’t use this.
<? error_reporting(E_ALL); ?>Reports all errors
<? error_reporting(E_ERROR | E_WARNING | E_NOTICE);?>
Will show only warning, notice & errors.
<? Echo error_reporting() ?>Will show your current error reporting level.
Hope this basic tutorial on Error Handling helped you.