Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php
error

What is a fatal error in PHP?

Educative Answers Team
widget

Fatal errors crash the program. There are three types of fatal errors in PHP:

  1. Startup fatal error: This error occurs when a system can’t run the code during installation.

  2. Compile time fatal error: This error occurs if a call is made to a non-existent code or variable.

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

<?php 
name("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.

RELATED TAGS

php
error
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring