error in php

TYPE OF ERRORS IN PHP

There are basically  four type of errors in php .

  1. Notice
  2. Warning
  3. Fatal error
  4. Parse error

 

Notice

It is  simple message to end-user .

it does not stop execution of script.

If we are trying to access undefined variable , output is notice message.

Example:

 

 

Output:   notice error

Hello

By default , we con not see notice message on  browser to display notice message, we should use error_reporting(E_ALL)function.

 

Warning:-

It is same as notice, does not stop execution of script. If we are trying to access undefined constants, output is warning message.

Constant is same as variable, but constant value con not be changed.

In php, using function, we can declare constants.

Using constant function , we can access constants.

 

Example:-

 

Output :

AAA

Warning

Hello

 

Fatal error

Fatal  error  stops the execution of script from the line when error is  occurred .

If we try to access undefined functions. Output is fatal error.

Example :-

Parse Error :-

If there is syntax mistake in the script, output is parse error.

Parse error stops execution of complete.

Example :-

 

Output :  parse error   (stops full script)

 

 

 

Output  :  first line  2nd line   3rd line 

Isset() :-

Using this function, we check whether the function is set with any value or not

Example:-

Output: 1(true)

Unset() :-

Using  this    function, we can delete the value of variable  .

Output :   false (nothing displays)