What is the output of the following code?
echo '1' . (print '2') + 3;
My answer was 15, but the answer is 214.
Why?
What is the output of the following code?
echo '1' . (print '2') + 3;
My answer was 15, but the answer is 214.
Why?
As executed, the code will do:
print '2' -> outputs 2
... print ALWAYS has a return value of 1, so the code becomes
echo '1' . (1 + 3); // with output '2'
This is simplified to
echo '1' . 4; // with output '2'
echo '14'; // output 2
final output: 214.