Problem pos increment

-1

Post-increment problem returning 67 being returned 7:

<?php 

$a = 10;
$b = 6;


echo ++$a; // pré incremento

echo "<br>";

echo $b++;

"<br>";

echo$b; // pós incremento

echo"<br>";



echo--$a;// pré decremento

 ?>
    
asked by anonymous 11.12.2018 / 15:38

1 answer

3

You've probably just forgotten to put a echo . So you should do what you want:

$a = 10;
$b = 6;
echo ++$a; // pre incremento
echo "<br>";
echo $b++;
echo "<br>";
echo$b; // pós incremento
echo"<br>";
echo--$a;// pré decremento

See running on ideone . And in Coding Ground . Also put it on GitHub for future reference .

In your code, you had to print 6 then you had a% of free% that disappears in the result and then you have to print the 7, since you have nothing separating them, it's 67.

    
11.12.2018 / 15:51