hi.
me newbie php.
the following code works fine:
PHP Code:
$count = -3;
while ($count <= 10) {
echo $count . ", ";
$count ++;
}
this code ALSO runs fine:
PHP Code:
$count = -3;
while ($count <= 10) {
if ($count == 5) {
echo "FIVE!, ";
} else {
echo $count . ", ";
}
$count ++;
}
So, how come THIS code seems to run in infinite loop? All I did was remove the curly-brace between the last echo and increment, and move it to the end.
PHP Code:
$count = -3;
while ($count <= 10) {
if ($count == 5) {
echo "FIVE!, ";
} else {
echo $count . ", ";
$count ++;
}
}
Notice there is no curly brace between echo and increment is first code example.