Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have seen a lot of people (first comment) hating die(); instead of exit;

As the follow-up comments on that post note, die and exit are the same - the attitude appears to be one of perception, with some feeling that one name is more appropriate in certain contexts than others.

But why does it matter? If they do the same thing, why should I care what name I use? Does death by any other name not smell as sweet?

share|improve this question
+1 for this funny question title. – Zeemee Aug 22 '11 at 6:56
up vote 5 down vote accepted

On a functional level, both work just fine and function the same.

However which one you prefer to use comes down to how one interprets the words die and exit.

exit has more appeal over die for me personally as a word that would be used to describe a programming function. It just seems more intuitive that way.

die however just comes off as something not technical whatsoever.

share|improve this answer
Die comes from Perl, which was like the PHP of web/cgi programming before PHP became the PHP of Web programming. :-) – Warren P Jul 20 '11 at 23:42

Personally I'd use die() on errors and exit() if I'm caught somewhere deep in functions and logic and come to the conclusion that I'm finished with the task at hand.

It's one of the famous quirks and debts of PHP. Fortunately, most times one can get rid of them by simply not using them or hiding them in some piece of low-level code no one will ever see and care about again.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.