Friday, 22 April 2011

Types of Errors in PHP



Errors in PHP

*We have four different types of errors in php.
1)  Notice Errors: Notice displays a massage to the end user and it will not stop the execution of the script.

Ex: If you are trying to access the undefined variable, the output is a notice massage. By default we cannot see the notices on the webpage. Because in “php.in” “error_reporting” is a configuration directive. The values of this directive is “E_ALL&~E_NOTICE”. It means browser displays all the errors expect notices.

*To display the notices, remove “&~E_NOTICE” from the configuration directives. Or use “error_reporting(E_ALL)” in the script , from where you want to display the notice massages.

2) Warning Errors: Warning errors are same as notice errors. Displays the same information to the users. Warning errors will not stop the execution of the script.

Ex: If you are trying to access the undefined constant then the output is warning error.
*In php we can declare the Constance using define keyword.
*define (<name>,<value>)
<?php
define ("city","hyd");
echo constant ("city")
echo constant ("stt")
echo "netline";
?>
*In above script “echo constant” is undefined constant.

Fatal Errors: Fatal errors stop the execution of the rest of the script. If you are trying to access the undefined functions, then the output is fatal error.
Ex:
<?php
function fun1()
{
echo "hi";
}
fun1();
fun2();
echo "next";
?>


Parse errors (syntax errors): If there is any syntax mistake in the script, the output is Parse errors. It stops the execution of entire script.
Ex: If you observe the below script, the second line does not contains “;” .
<?php
echo "line1";
echo "line2"
echo "line3";
?>

2 comments:

  1. sir good evening this is karunakar ,present jquery class run any batch please give information

    ReplyDelete
  2. sir i want to know when this 7.30pm session will end, sir due to emergency i have to go to my town, so sir please provide remaining content of that remaining session, my email Id: mdzabeerahmed@gmail.com.... thanking you.............

    http://www.danphp.com/p/php-notes-php-tutorial-notes.html

    ReplyDelete