Friday, 30 January 2015

Errors In Php

There are three basics errors in php:

Notices:

These are non-critical errors means, if accessing a variable which never defined php show notice error for it.

<?php

echo $myvaiable; 
// print output
//Notice: Undefined variable: myvariable

?>

Warnings:

These are not critical but these are serious errors mean if user include file but it has some problem in  loading so php show warning errors.

<?php

// including file
include 'file_name.php'

 
// this will generate a warning or E_WARNING because file loading is fail 
//print output 
//Warning: include(filname.php): failed to open stream: No such file or directory
//Warning: include(): Failed opening 'filname.php' for inclusion 

?>

Fatal:

These are critial and important errors means if user call a function which not exits then its show fatal error and stop the script

<?php

// call a non-existent function
// this will generate a fatal error (E_ERROR)
callmyfunction(); 

/print output
//Fatal error: Call to undefined function callmyfunction() 

?>

No comments: