- Fatal error
- Parse error
- Startup fatal error – This will occur when the code cannot be executed with the PHP environment due to the fault that occurred at the time of installation.
- Compile time fatal error – This kind of error will occur when we attempt to use nonexistent data like file, class, function and etc.
- Runtime fatal error – This will occur during execution. It is similar to compile time fatal error, except Compile time fatal error is generated by the Zend engine based on the time of occurrence.
Example: PHP Fatal Error
|( ! ) Fatal error: Call to undefined function myFunction() in C:\xampp\htdocs\demo\today\demo.php on line 2|
|( ! ) Parse error: syntax error, unexpected 'echo' (T_ECHO), expecting ',' or ';' in C:\xampp\htdocs\demo\today\demo.php on line 3|
PHP will create warning message for sending them to the user without halting the execution. An example for warning messages to be created is the divide by zero problem that is as shown in the following program.
<?php $numberOne = 0; $NumberTwo = 10; $result = $NumberTwo/$numberOne; echo $result; ?>In the above program, since $numberOne has the value 0 and any number divided by zero is undefined, the line on which the division is made will create the following warning notices followed by the string returned by the echo statement with an empty value for $result variable. Meaning that, even after the occurrence of the warning error, the echo statement is executed.
|( ! ) Warning: Division by zero in C:\xampp\htdocs\demo\today\demo.php on line 4|
NoticeLike other PHP error messages, notice message can be created automatically or by the user by using the PHP trigger_error() function.It is used to send messages to the browser to make the user know about the problem of the code is any, which might cause an error.
For example, the following program starts with incrementing an uninitialized variable $result to print the incremented value to the browser. Since $result is not initialized, it will automatically trigger the notice error on executing this script.
<?php $result += 5; echo "RESULT: ". $result; ?>
|( ! ) Notice: Undefined variable: result in C:\xampp\htdocs\demo\today\demo.php on line 2|
E_ERROR: A fatal error that causes script termination E_WARNING: Run-time warning that does not cause script termination E_PARSE: Compile time parse error. E_NOTICE: Run time notice caused due to error in code E_CORE_ERROR: Fatal errors that occur during PHP’s initial startup (installation) E_CORE_WARNING: Warnings that occur during PHP’s initial startup E_COMPILE_ERROR: Fatal compile-time errors indication problem with script. E_USER_ERROR: User-generated error message. E_USER_WARNING: User-generated warning message. E_USER_NOTICE: User-generated notice message. .E_STRICT: Run-time notices. E_RECOVERABLE_ERROR: Catchable fatal error indicating a dangerous error E_ALL: Catches all errors and warnings