Error types

PHP has a number of possible errors that it might return, all of which mean something different and are treated differently. Here is the complete list:


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 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 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.


This is a catch-all error type, which means "all errors combined".

All warnings and notices can usually be recovered from without too much problem, however errors are critical and usually mean "you would not want to recover from this".

User errors, user warnings, and user 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.

Notices are generally very minor things - using an uninitialised variable, for example - that may be a sign that you have got a hidden bug lurking in there, but it may also be there by design, as notices are generally quite strict.


Want to learn PHP 7?

Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!

If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: Choosing what types of errors you see >>

Previous chapter: Troubleshooting

Jump to:


Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.