Here is what I am doing (php)
<?php
for($i = 0; $i <= 30; $i+2)
{
echo $i;
}
?>
It drives me nuts,coz it does not work [prints nothing, browser keeps trying to load]. But if I change $i+2 to $i++, it works, and if I change it to $i+1, that does not work either.
I am out of my wits. What is going wrong?
$i++is equivalent to$i = $i + 1, note the assignment operator=, it isn’t present here$i + 2adds but doesn’t update …since
$iis never updated, you have an infinite loop, where the script will probably reach the allowable time for processing and terminate.http://php.net/manual/en/function.set-time-limit.php