The problem with loop statement output is that you can use for + switch to output a specified statement, for ($ i1; $ I & lt; 10; $ I ++) {& nbsp; switch ($ I) {case1: echo & quot; 1 & quot; echo & quot; & lt; BR & gt; & quot; & nbsp; break; & nbsp; case2: & nbsp; echo & loop statement output
You can use for + switch to output a specified statement,
For ($ I = 1; $ I <= 10; $ I ++)
{
Switch ($ I)
{
Case 1:
Echo "1 ";
Echo"
";
Break;
Case 2:
Echo "2 ";
Echo"
";
Break;
Case 3:
Echo "3 ";
Echo"
";
Break;
Case 4:
Echo "4 ";
Echo"
";
Break;
Case 5:
Echo "5 ";
Echo"
";
Default:
Echo "OK ";
}
For example, the preceding statement can output a number when I is equal to a certain number,
But now 1-5 numbers are instantly output. how can I output these five numbers every several seconds? for example, output 2 every five seconds after output 1, output 3 in 5 seconds
Another problem is that the above code can only be output once. that is to say, 1-5 numbers are not output after being Output. Is there any way to output 1-5 numbers cyclically?
That is to say, after 1-5 is output, I is converted to 1 and then output again.
------ Solution --------------------
1. Add sleep (5)
2. switch ($ I % 5)
------ Solution --------------------
If you add a timer to him and you find it useful again, the problem is that you are not aware that php is processing all the code and then outputting the result.
If you want to display it like a typewriter, use js to control it.
Discussion
Using the sleep function,
The result will still be output at a time, and no output will be made. after 5 seconds, a form will be output again.
Changing the ajax call time to 30 seconds is the same and cannot be output one by one.
------ Solution --------------------
Latency 5 seconds output, required
Flush ();
Ob_flush ();
Sleep (5 );
For ie browsers
Echo $ I. str_repeat ('', 256 );
That is, each output cannot be less than 256 bytes.
Output_buffering = off