PHP Error Types

Types of Errors in PHP

An error is a unwanted result of program. Error is a type of mistake.
An error can also be defined as generate wrong output of program caused by a fault.
An error message display with error message, filename and line number.

An error can be categorized in :

  • Syntax Error
  • Logical Error
  • Run-time Error

The syntax error is a any mistake in symbol or missing symbol in a syntax.
Logical error means you expressed something that is logically incorrect and it will produce unwanted result.
The logical error occur at run-time.
The run-time error produced by a logical error. Both logical error and run-time error are same thing.

In PHP there are four types of errors.

  • Notice Error
  • Fatal Error
  • Waring Error
  • Parse Error

PHP – Notice Error

Notice error occurs when we use a variable in program which is not defined then it produce notice error.

Notice error code execution of script does not stop.

Notice Error Example

The out put of notice error :

PHP_notice_error

PHP Notice Error Example

In above example we use $series variable but it is not defined, so it will produce notice error but the execution of script does not stop.

PHP Notice Error Example

<?php

$a=5;
echo “The result = ” . $b;

?>

The out put of php example : In this php example we declare a variable $a, but we use another variable $b in program which is not defined, so it will also generate notice error like below.

PHP Notice Error Example

PHP Notice Error Example


PHP – Fatal Error

Fatal error is critical error and it is stop the execution of script immediately.
Fatal error occurs when we call undefined functions or class.

Fatal Error Example

The output o example :

PHP Fatal Error Example

PHP Fatal Error Example

In above example we declined “sum()” function but in program we call “mul()” function which is not defined in program, so it will produce fatal error and stop the execution of script.


PHP – Warning Error

A warning error does not stop the execution of script. warning error not a critical error.
A warning error occurs when we pass wrong parameter in function or we include external file using include() function but the file doesn’t exist then display warning error.

Warning Error Example

The out put of php example :

PHP  Warning Error Example

PHP Warning Error Example


PHP – Parse Error

A Parse error occurs if there is a mistake in a syntax. When parse error occurs the execution of script will be terminated.

Parse Error Example

Above example we declare two variable $a and $b, but in $b variable we missing the semicolon(;) so it will produce parse error like below.

The out put of php example :

PHP Parse Error Example

PHP Parse Error Example

Leave a Reply

Your email address will not be published. Required fields are marked *

6 + 1 =


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">