I know it's a good way to catch an exception but why not just make it into a simple if..else statement and run a block of codes then used die to stop the code following it from executing or echo to enable the scripts following it from executing. What's the difference?
AngelicOne 4 Posting Whiz
Recommended Answers
Jump to Postdie() just stops execution. Throw is a way to notify the caller that an error has occured. The caller can then handle the problem.
Jump to PostThat will be your choice. You can throw an exception when a function you write fails, or you could do it by using a return value. It all depends on how you want to write your own code. For example:
function mysqlConnect() { if (! mysql_connect(...)) return …
All 5 Replies
pritaeas 2,211 ¯\_(ツ)_/¯ Moderator Featured Poster
AngelicOne 4 Posting Whiz
pritaeas 2,211 ¯\_(ツ)_/¯ Moderator Featured Poster
AngelicOne 4 Posting Whiz
pritaeas 2,211 ¯\_(ツ)_/¯ Moderator Featured Poster
ko ko commented: Good answer. @pritaeas, Zero13 +8
AngelicOne commented: thanks +3
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.