E Online Support - Free Software Download
What are the differences in die() and exit() in PHP
Differences in die() and exit() in PHP
Jeetender
Answer
1

Die is used to display a message and exist the script. It may be used to print alternate message . instead of showing error it will show the user friendly message. die is only used to print string messages . value of variables cannot be print with die function.
<?php
die("this is Php die example");
//this will print the message.

$x="hello test";
die($x)
//this will show blank screen.
?>

<?php
$con= mysql_connect("localhost","root","") or die('connection not found');
 ?>

<?php
$x=10;
$y=10.0;
if($x==$y)
{
die('both are equal');
}
else
{
die('both are not equal');
 ?>



The PHP Exit( ) Function Is Alias Of PHP Die( ) Funciton. It Is Also Used To Print Message.

<?php
$con= mysql_connect("localhost","root","") or exit('connection not found');
 ?>

<?php
$x=10;
$y=10.0;
if($x==$y)
{
exit('both are equal');
}
else
{
exit('both are not equal');
 ?>
Question*:
Description*:
Script:
Related To:
 PHP    HTML    CSS    JAVASCRIPT    JQUERY   
 AJAX    WINDOWS    GAMES    DRIVERS    MAC   
 LINUX    MOBILE    GADGETS   
Security Code:
1957
Enter Security Code:
 
Facebook   Linkedin   Skype   Twitter