PHP Error Handling: What are the different types of errors in PHP?

Basically there are three major types of errors in PHP
Notices,Warnings and Fatal errors


Notices are small, non-critical errors that PHP encounters while executing a script.By default, such errors are not displayed to the user at all and these will not cause script termination.
Condition like Accessing a variable that not define.


Warnings are more severe errors.By default, these errors are displayed to the user, but they do not result in script termination.
Condition like attempting to include() a file which does not exist.


Fatal errors
Errors are critical errors that terminate script and stop.These errors cause the immediate termination of the script, and PHP’s default behavior is to display them to the user when they take place.
Condition like
1 Instantiating an object of a non-exist class
2 Calling a non-exist function
3 Missing semicolon (Parse Error)
4 Missing braces (Parse Error)
5 Destroyed DOM


PHP has a number of possible errors that it might return, all of which mean something different and are treated differently.
These are as follows.

Fatal run-time error. Script execution is terminated because the error cannot be recovered from.

Run-time warning. Execution of the script is not terminated because the situation can be recovered from.

Compile-time parse errors.Only generated by the PHP parser.

Run-time notice. Execution of the script is not terminated, but it is possible there is an error in your code.

Fatal error in PHP’s internals. Indicates a serious problem with your PHP installation.

Compile-time warning. Generally indicates a problem with your PHP installation.

Fatal compile-time error. This indicates a syntax error(problem with your script) in your script that could not be recovered from.

This indicates a non-fatal syntax error in your script

User-generated error message. This is generated from inside PHP scripts to halt execution with an appropriate(user-defined) message.

User-generated warning message. This is generated from inside PHP scripts to flag up a serious warning message without halting execution.

User-generated notice message. This is generated from inside PHP scripts to print a minor notice to the screen, usually regarding potential problems with scripts.

Catchable fatal error indicating a dangerous error

This is a catch-all error type and warnings.


User errors,warnings and notices are all generated using the trigger_error() function, and you should use them in your own code to handle possible errors that others (or indeed you) might make when calling your own functions.