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?
Asked
Active
Viewed 223 times
0

Giorgi Tabatadze
- 19
- 8
-
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 Answers
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
-
2
-
-
This is the way to go. Now if only PHP had a kill() function for extra brutality! – Andrew Aug 14 '14 at 23:20
-
Does the kill(); function is more safe then die(); or exit(); ? – Giorgi Tabatadze Aug 14 '14 at 23:21
-
1There's no kill() function. @Andrew just said if PHP had that function – kimbarcelona Aug 14 '14 at 23:27