Page 1 of 1

or die() question

Posted: Sun Mar 23, 2003 11:19 am
by Guy
do I always have to do die() after an or when calling a function?

Code: Select all

(mysql_connect() or die("text") )
or is it just a convention?
all the examples I saw had die() after the or.
thanks
Guy

Posted: Sun Mar 23, 2003 11:28 am
by twigletmac
No you don't - it's used to prevent further code from running if an important function fails. For example if you can't connect to a database you wouldn't then want to try and query it because you'll just get loads of errors.

You don't see it used much except when it comes to database functions.

Mac

Yes,

Posted: Sun Mar 23, 2003 11:34 am
by Guy
but instead of stopping everything you can instead return something
that indicates failure and catch it.
I always thought that die() is too harsh.
Guy

Posted: Sun Mar 23, 2003 11:39 am
by twigletmac
Of course you can. Or die() isn't always appropriate.

Mac