I want to increase the value of a variable by using the increment operator in heredoc. My current code is given below...
$counter = 0;
for($i = 0; $i<10; $i++):
echo <<< EOT
$counter++ <br/>
EOT;
endfor;
Its output is...
0++
0++
.
.
Mean post-increment operator is not working.
I have also tried pre-increment, like given below...
echo <<< EOT
++$counter <br/>
EOT;
Its output is...
++0
++0
.
.
Mean pre-increment operator is also not working.
I have also tried to put increment operation inside curly braces, like given below...
echo <<< EOT
{++$counter} <br/>
EOT;
But again no luck. Output is....
{++0}
{++0}
.
.
I have also searched it on google but didn't find anything useful.
I know if I can increase value before heredoc then I can print it in here doc correctly
$counter = 0;
for($i = 0; $i<10; $i++):
++$counter;
echo <<< EOT
$counter <br/>
EOT;
endfor;
It works fine.
But I want to use increment operator in heredoc, just like we use in case of single or double quoted with echo.
But it seems like heredoc doesn't support increment operation.
