Explain the output: echo 'to'.print (' 2 ') + 2;

I ran this and it will produce 4to1

But you need an explanation of how it outputs 4to1

Can anyone explain?

+6
source share
1 answer

print('2')+2 this piece of code will print the number 4 for the start of the line. Print will be allowed before echo .

Then the echo function will be enabled, and echo will contain to as the first, and if you use print() inside the echo, it will print the function parameter as the first, and then number 1 .

Like Andreas Scheibleger mentioned in the comment, 1 comes from the return value of Print , which is always 1 because it is not possible to execute the print() echo function.

For instance:

 echo print(""); // 1 echo print("test"); // test1 
+9
source

All Articles