What is an Error?
An error may be defined as unexpected condition due to invalid program statement(s). It is also defined as deviation from correctness. It is caused by fault(s). An error message with the line number, filename and a message about the error description is sent to the browser.

Types of Error In PHP:

In PHP, we have 4 major types of errors:

  1. Warning errors
  2. Notice errors
  3. Fatal errors
  4. Parse errors

Run Time Errors:
In PHP, we have 3 types of run time errors which are as follows:

1. Fatal Errors:
They are serious errors. They may be caused if someone tries to instantiate an object of a non existing function or a non existing class. They are critical errors which halt the script execution.

2. Warnings:
They are typically less serious errors but they are severe too. They may be caused as a result of an attempt to include a file which doesn’t exist. These errors are also displayed to the user. They don’t cause halting of script execution.


3. Notices:
They are usually small level errors. They may occur when somebody tries to access a variable which has not been defined. These errors are not displayed to the user, but the default behavior can be altered.

4. Parse Errors:
They are basically syntax errors. If the developer commits a mistake with respect to syntax in PHP, then he may have to face parse error. Such errors may stop the execution of the whole script. These types of errors may occur due to different reasons, the most common reasons are as follows:

  • Braces are not closed.
  • Semicolon is missing
  • Developer forgot to close quotes
  • There are extra, or any missing parentheses

Comprehensive List of Errors in PHP:

To better deal with the errors or facilitate debugging, it is necessary to understand the type of error and its cause. In this article, we discussed the major types of errors and their usual causes. Below is a more comprehensive list of PHP errors:

E_PARSE It shows parse error occurred during compilation time.
E_NOTICE It is a run time error which is caused due to error in script.
E_ERROR This error terminates script execution. It is a fatal error
E_ALL They catch all types of warnings and errors.
RECOVERABLE_ERROR They are serious errors which are catchable.
E_STRICT They are Run time notices.
E_USER_NOTICE It indicates notice message generated by the user.
E_USER_WARNING It indicates warning message generated by the user.
E_USER_ERROR It indicates a user generated error message.
E_COMPILE_ERROR It indicates compile time error problem.
E_CORE_WARNING This is a type of warning which occurs at the time of initial startup of PHP
E_CORE_ERROR This is a fatal error which usually appears during installation process.
E_WARNING It doesn’t halt script execution. It is a run time warning.

I hope this article was useful to learn about PHP errors. Keep this page bookmarked, and as you face various PHP errors, refer back here. Soon you’ll be an expert in diagnosing PHP errors and will know these errors like the back of your hand. If you have any questions, get in touch with me. I’ll be happy to help.


Types of Errors In PHP

Leave a Reply

Facebook Page

Facebook Page Loading...