0


I know PHP two function die(); and exit();
I am using both function when I want to stop everything.
These two functions are doing the same thing?
Can I only use one of them?

  • They're equivalent, as stated explicitly in the documentation. However, I would _strongly_ advise to only use them on 'success' conditions, not on errors. If you want to stop on an error, use a `trigger_error("Tell me what actually went wrong". E_USER_ERROR);` (which would help serveradmins find those in the logs...) – Wrikken Aug 14 '14 at 23:17

1 Answers1

1

There's no difference - they are the same.

PHP Manual for exit:

Note: This language construct is equivalent to die().

PHP Manual for die:

This language construct is equivalent to exit().

Andrew
  • 1,128
  • 1
  • 13
  • 27