IF statement fails

302 Views Asked by At

I have created a simple a php script I do not understand what could be wrong with it. I believe it should echo "Died!" because the die function is executed right

if (die()){
    echo "Died!";
}

Please help, thanks. (I'm currently using php 4.3.9 and apache)

1

There are 1 best solutions below

6
Marc On

Die is equivalent to exit(), per PHP:

"exit — Output a message and terminate the current script"

The script should terminate before evaluation is complete and the echo will never happen.

See: http://php.net/manual/en/function.exit.php

There may be a few exceptions that work around this, but it is safe to say die is the last thing to be executed, not echo.

Since the script is stopping, the return will not happen, exit stating "No value is returned.".