Home » Php » php – exit(); die(); return false;

php – exit(); die(); return false;

Posted by: admin April 23, 2020 Leave a comment

Questions:

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?

How to&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.

Answer:

According to docs PHP: exit Manual die() is an alias to exit() so they do the same function and that is to END the script.

The return statement ends a function and not the entire script, and returns the value that you choose.