manokarthick karthick manokarthick karthick - 1 year ago 102
PHP Question

how to display string with echo that has die function

echo 'SKU is B001'.die();

in the above line due to die at end, the echo not displays the string.

how die works here?

Answer Source

The order of evaluation is as following:

echo('SKU is B001'.die());

PHP needs to evaluate the parameter for echo before it can call echo:

'SKU is B001'.die()

The . operator now needs to evaluate 'SKU is B001', which is just 'SKU is B001' and the result of die() before it can concatenate the strings;

Once it calls die, the execution of the program stops.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download