Possible Duplicate:
what are the differences in die() and exit() in PHP?
I am totally confused in the difference of die
and exit
.
Most programmers use die
like this.
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); //don't see mysql_* problem it is just example
if (!$link) {
die('Could not connect: ' . mysql_error());
}
and using exit
like this
$filename = '/path/to/data-file';
$file = fopen($filename, 'r')
or exit("unable to open file ($filename)");
According to there functionality , I don't think so there is any difference because both terminates the execution of the script.
My question is
1) Can I interchange die with exit and vice-versa in these examples?
2) And the difference between these also.
Cheers...
According to Die it is Equivalent to exit. So yes, you can interchange them .