visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
316 experts, 1194 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: PHP :: die()ing without really die()ing, on error in class function


By: FiatLink Belgium  Date: 31/12/2004 10:22:40  English French  Points: 50 Status: Answered
Quality : Excellent
Hi,

I've created a class which has a WriteError() method. WriteError() displays a table with error information. Once this does its thing, I want it to stop doing anything else. If I enter "die()" or "exit;" the information isn't displayed on the page.

Is there an intermediate way of getting it to show the information and stop without an all-out die()?
By: VGR Date: 31/12/2004 10:26:21 English  Type : Answer
back into your OOP design problems ? :D

Anyway, you've three solutions :
1) flush() output before exitting; or die()ing - this is not guaranteed to work.
2) without die()ing or exit()ing, transmit the error to the upper level (caller) :
2a) with Exceptions in PHP5+ - I never tested this myself.
2b) return the error code/message to the caller - the classical modular way with a function() - and handle it at that level. That's my way.

Regards,

VGR
By: FiatLink Date: 08/01/2005 21:49:58 French  Type : Comment
J'opte pour la solution 2b. Merci 8-)

Do register to be able to answer

EContact
browser fav
page generated in 239.890810 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page