0

Hi,

I just want to find out which is better?

Thanks

......
echo "Database connection error";
exit;

OR

......
die ("Database connection error");
4
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by phpbeginners
0

in other languages there's a difference. in php they're the same. Traditionally in programming, you exit when things all work correctly and you just want to quit, and you die on errors.

-1

die — Equivalent to exit()

//exit program normally

exit;
exit();
exit(0);

//exit with an error code
exit(1);
exit(0376); //octal

I haven't try die(1) or die(0376) try it! :-)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.