What is the output of the following PHP code?

the output of the following code?

echo '1' . (print '2') + 3;

      

I tested and the result is 214, but why 214?

if i code:

echo (print '2') + 3; 

      

the result is 24 Then, echo '1'. '24'; should be 124.

Confused ...

+3


source to share


1 answer


When the expression is parsed, the "print" statement immediately writes its output. So the first is 2. By definition, its return value is 1.

So the remaining expression is the character 1 followed by the numeric expression 1 + 3. Therefore, 1 and 4.



214

+8


source







All Articles