What are the main error type in php?

212 Views

What are the main error type in php?

Error type in php

There are three main error type in php

  1. Notice Error
  2. Warning Error
  3. Fatal Error
 

Notice Error

It is a simple and non critical error which is occur during script execution. It throw a error message but rest of code execute normally. This error generally occurs when you try to access the undefined variable.

 <?php

$var="www.StudyZone4U.com";

echo $var1; // variable "$var1" is not define, so it throw a notice error

?>

Warning Error

It throw a warning error however rest of the script execute successfully. The main reason for warning errors are to include a missing file or using the incorrect number of parameters in a function.

 <?php

echo "Warning Error!!";

include ("hello.php"); //if this file is not found then it will throw a warning error

?>

Fatal Error

It terminate the script execution when fatal error occurred. If you are trying to access the undefined functions, then the output is a fatal error.

 <?php

function welcome()

{

echo "StudyZone4U.com";

}

hello(); // Function "hello()" is not defined.
         //It generate a fatal error and terminate the script execution.

?>

 

Tags:-
PHP