Wednesday 16 July 2014

Die() & Exit() Function's in PHP.

The Die() function in php is used for generally printing the message or we can say output.


For Example (i)-


<?php

$conn=mysql_connect("localhost","root","") or die("connection not found");

?>


Example (ii)-

<?php

           $x=5;
           $y=5.2;

if($x==$y)
{
           exit('both are equal');

}

else
{
           exit('both are not equal');
}

?>

The exit( ) function in php is alias of die( ) funciton. It is also used to printing the message.


For Example (i)-


<?php

$conn=mysql_connect("localhost","root","") or die("connection not found");

?>


Example (ii)-


<?php

$x=5;
$y=5.2;

if($x==$y)
{

exit('both are equal');

}

else
{

exit('both are not equal');
}

?>

Full list of Aliases function you will find on following URL:

http://php.net/manual/en/aliases.php


Posted By -Amit Tiwari

No comments:

Post a Comment