type of error using examples
Notice : Notice is a message to the end user it won't stop the execution of the script .
ex:=if we are trying to acess undefined variables , then output is notice.
we can't see the notice on web page directly because in php.ini we have one configuration directives that is
erro_reporting, the value of this directive id is E_ALL
.
error_reporting_(e_all)
<?php
error_reporting(E_ALL);
$a=100;
echo $a;
echo $b;
?>
/*output
100
Notice: Undefined variable: b in F:\xampp\new\htdocs\php\var_dump.php on line 5
*?
but it will not stop the execution .
<?php
//error_reporting(E_ALL); put it into comments
$=100;
echo $a;
echo $b;
?>
/* output
100
*/
warning:-warning message will not stop the execution of the script , if we are trying to access the undefined constant
the output is warning.
<?php
define("a","100");///declare constant
echo constant("a");
echo constant ("city");//warning
echo "scott";
?>
/*output
100 // executed
Warning: constant() [function.constant]: Couldn't find constant city in F:\xampp\new\htdocs\php\var_dump.php on line 4 // showing error
scott // executed
*/
Fatal error;
fatal error stops the execution of rest of the script if we are trying to call undefined function the output is Fatal error.
<?php
echo "firt executable line form function 1";
function fun1()
{
echo "From function 1";
}
echo (fun1());
fun2();
?>
/*output
Executable line
From function 1 execution
Fatal error: Call to undefined function fun2() in F:\xampp\new\htdocs\php\var_dump.php on line 9
*/
<?php
fun2();
echo "firt executable line form function 1";
function fun1()
{
echo "From function 1";
}
echo (fun1());
?>
/*output
Fatal error: Call to undefined function fun2() in F:\xampp\new\htdocs\php\var_dump.php on line 2
Notice : Notice is a message to the end user it won't stop the execution of the script .
ex:=if we are trying to acess undefined variables , then output is notice.
we can't see the notice on web page directly because in php.ini we have one configuration directives that is
erro_reporting, the value of this directive id is E_ALL
.
error_reporting_(e_all)
<?php
error_reporting(E_ALL);
$a=100;
echo $a;
echo $b;
?>
/*output
100
Notice: Undefined variable: b in F:\xampp\new\htdocs\php\var_dump.php on line 5
*?
but it will not stop the execution .
<?php
//error_reporting(E_ALL); put it into comments
$=100;
echo $a;
echo $b;
?>
/* output
100
*/
warning:-warning message will not stop the execution of the script , if we are trying to access the undefined constant
the output is warning.
<?php
define("a","100");///declare constant
echo constant("a");
echo constant ("city");//warning
echo "scott";
?>
/*output
100 // executed
Warning: constant() [function.constant]: Couldn't find constant city in F:\xampp\new\htdocs\php\var_dump.php on line 4 // showing error
scott // executed
*/
Fatal error;
fatal error stops the execution of rest of the script if we are trying to call undefined function the output is Fatal error.
<?php
echo "firt executable line form function 1";
function fun1()
{
echo "From function 1";
}
echo (fun1());
fun2();
?>
/*output
Executable line
From function 1 execution
Fatal error: Call to undefined function fun2() in F:\xampp\new\htdocs\php\var_dump.php on line 9
*/
<?php
fun2();
echo "firt executable line form function 1";
function fun1()
{
echo "From function 1";
}
echo (fun1());
?>
/*output
Fatal error: Call to undefined function fun2() in F:\xampp\new\htdocs\php\var_dump.php on line 2
0 comments: