3. While loops in PHP error


#1

this is my code and they report: infinite loop and can't pass this part.
$i=2;
while($i==2) {echo "ff"; $i = 3;}
I dont understand.
Once I F5 browser, it always displays : $i=2; while($i)
and 1 report: The program took too long to finish. Check your code for infinite loops and try again.
Plz help me.


#2

$i = 2;
while($i == 2) { // should be $i < 3 if you want to print "ff" one time
   echo "ff"; 
   $i++; // or $i += 1;
}

Look to this example: The PHP while Loop


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.