What is a fatal error in PHP?
Fatal errors crash the program. There are three types of fatal errors in PHP:
-
Startup fatal error: This error occurs when a system can’t run the code during installation.
-
Compile time fatal error: This error occurs if a call is made to a non-existent code or variable.
-
Runtime fatal error: This error occurs while the program is running, and will cause the program to quit.
The following code tried to call a function name without declaring the function. This gives a fatal error:
<?phpname("John", "Smith");echo 'Success!';?>
Notice how the print statement is not executed. This is because, as soon as a fatal error is thrown, the code stops compiling.
Solution
- Look for the undeclared variables as given in the error.
- If you are using inbuilt functions, ensure that there is no typo and the correct function is called.
- Check if the spellings are correct.
Free Resources
Copyright ©2026 Educative, Inc. All rights reserved