Hi,
I just want to find out which is better?
Thanks
......
echo "Database connection error";
exit;
OR
......
die ("Database connection error");
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.
you can use exit("Database connection error"); no need to echo;
exit("Database connection error");
is nice one!
Thanks guys
I think die() because it shows exception
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! :-)
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.