Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

exit(); die(); return false; [duplicate]

Tags:

php

Possible Duplicate:
what are the differences in die() and exit() in PHP?

I guess the main question is what is the difference between the 3 exactly?

What is the correct semantic usage for each one of these?

From what I see return false; can discontinue a function whereas die(); and exit(); will prevent any further code running at all.

Is this correct?

like image 239
daryl Avatar asked Dec 13 '11 14:12

daryl


1 Answers

die() and exit() are precisely identical; they halt the entire PHP program and return to the OS. They're two different names for the same function.

return, on the other hand, ends a function call and returns to the caller. At the end of a program, return sets the status value that is returned to the OS; the program is going to exit no matter what.

like image 140
Ernest Friedman-Hill Avatar answered Oct 03 '22 20:10

Ernest Friedman-Hill