+ 2

Can anyone help in understanding this code in php

https://code.sololearn.com/wOGa4C9gkDJK/?ref=app

10th May 2017, 8:40 AM
Player
Player - avatar
2 Respuestas
+ 9
Actually your code is: <?php echo 1 . print(1) . 1; ?> The 'print' behaviour is the same that 'echo', and always return 1 ( http://php.net/manual/en/function.print.php )... So, your instruction will output the first integer one as a string "1", the dot is for concatenate string, so returned value of print calling is appended to the output ( "1" ), and the next dot append the last integer one ( "1" ). The 4th one as output is produced by execution of print(), and occurs before execution of echo ( which require the returned value of print() ^^ ). To verfy that, try to change the print() argument: <?php echo 1 . print(2) . 1; ?> ;)
10th May 2017, 9:17 AM
visph
visph - avatar
+ 2
echo 1 . print(1) . 1; echo 1.1.1.1 because print() always return 1
10th May 2017, 9:06 AM
Calviղ
Calviղ - avatar