Error in PHP is a problem or mistake that happens when running a PHP script. These errors can occur for various reasons, like typing something incorrectly or using outdated code or missing some included file etc.

There are various types of errors in PHP but it contains basically four main type of errors.

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

1.  Parse Errors:

Parse errors occur during the parsing of PHP scripts, typically due to syntax errors.

Example: Missing semicolon at the end of a statement.

2.  Fatal Errors:

Fatal errors are serious issues that cause the script to halt immediately.

Example: Including a non-existent file using require.

3. Warning Errors:

 Warning errors are non-fatal issues that don't stop the script execution but indicate potential problems.

Example: Using an undefined variable.

4. Notice Errors:

Notice errors are less severe than warnings and usually indicate minor issues or potential problems with the script.

Example: Accessing a non-existent array key.

PHP error constants :

Here are some common error constants in PHP:

  • E_ERROR: Represents fatal errors that cause script termination.
  • E_WARNING: Represents non-fatal runtime warnings.
  • E_NOTICE: Represents runtime notices indicating potential issues.
  • E_PARSE: Represents syntax errors detected during script parsing.
  • E_DEPRECATED: Represents notices for deprecated features.
  • E_STRICT: Represents recommendations for coding standards.
  • E_ALL: Represents all types of errors and warnings.
  • E_CORE_ERROR, E_CORE_WARNING: Represents errors and warnings that occur during PHP's startup sequence.
  • E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE: Represents errors, warnings, and notices generated by user code.
  • E_COMPILE_ERROR, E_COMPILE_WARNING: Represents errors and warnings that occur during script compilation.