tags:

views:

888

answers:

7

in PHP Does die() gives anything in return when we use it?

+13  A: 

In PHP the function die() just quit running the script and prints out the argument (if there's any).

http://us.php.net/die

Ivarska
+5  A: 

Why don't you have a look at the wonderful documentation of PHP? It even contains information about die()

soulmerge
Poor guy. He'd have to click *again* to see what exit() returns. Spoiler: the answer is void
Stephan202
i have checked that but still wanted to ask that question here as i wasnt very much sure that whatever i have read is true .
developer
The php docs are *the* place to look such things up. Nothing can be truer than the information there except it is a documentation bug (but if you want to be *that* sure better check php's bug tracking system and/or run a test code). By the way: Since die() finishes the execution of PHP, it is quite irrelevant, what the return value is (since the program stops at that point).
soulmerge
A: 

Check out: http://uk2.php.net/die

Lloyd
+1  A: 

It does not return. The script is terminated and nothing else is executed.

rikh
+1  A: 

It is the same as exit() and according to documentation it returns nothing

victor hugo
+1  A: 

There's no reason to return something in die/exit. This function terminates php interpreter process inside and returns exit-code to shell. So after calling die() there is no script execution as far as there is no interpreter process which executes the script and that's why there is no way to handle function's return.

Jet
A: 

I have tried this and it worked in google chrome and FF, but not so good in IE7/8

if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) { die("" . include ("empty.php") . ""); }

Basically, a form is filled out asking for username, password and verify password.. if the person filling in the registration form does not fill out all the fields in the form the die function calls empty.php using the include function.

To be honest, Im not sure its actually supposed to work like this, but it seems to. So maybe someone can work from that to find a proper solutions to calling something with the die function.

Eoin H