-5

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 Answers1

0

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.".

Marc
  • 1,895
  • 18
  • 25
  • 1
    There is nothing to work. echo will not fire, that is how it works. – Marc Aug 20 '18 at 02:32
  • 3
    @AbdulBaariel-Shad ... you seem so certain that people are wrong, yet you have an issue you cant explain !!! maybe , just maybe, consider **you** are wrong. – YvesLeBorg Aug 20 '18 at 02:34
  • sorry dude, this is how it works. This sandbox goes down to 4.4, same result. http://sandbox.onlinephpfunctions.com/code/c62b4bba420deee3b5feeb8efcfa2fb53bed8680 – Marc Aug 20 '18 at 02:37
  • 1
    clearly that emulator is wrong because it is 4.4 and 4.3.9 also I'm neber wrong – Abdul Baari el-Shad Aug 20 '18 at 02:40
  • 1
    There is nothing wrong with making a mistake. I can confirm that exit (which die is an alias of) will output a string if you pass them as a parameter and will not if you do them after. You don't have to take our word for it, it is all documented here: http://php.net/manual/en/function.exit.php – Aziz Saleh Aug 20 '18 at 02:44
  • 1
    that's not official in fact my built in browser security that website has a keylogger (using coccoc) – Abdul Baari el-Shad Aug 20 '18 at 02:47