Hi!

Can anybody please explain this-

<?php


$num=5;
echo($num.++$num);
echo("<br />".$num);

?>

prints:

66
6

while

<?php


$num=5;
echo($num++.++$num);
echo("<br />".$num);

?>

prints:

57
7

how exactly is the parsing done?

There seems to be an interesting and undocumented precedence taking place with the concatenation operator. It seems

echo $num . ++$num;

prints out 66. Whereas

echo $num , ++$num;

prints out 56

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.