Ec (2); while statement Execution code block, if only calculated as true in the specified condition. If the condition becomes false, the statement in the loop stops execution and controls the loop passed to the statement. The syntax of the while loop is as follows: while (condition) {& nbsp; codetobeexecuted;} in the relevant statement, but it is always closed (braces for the opening and closing ceremonies) the code block symbol tells PHP code to know which lines should pass through the loop. While script ec (2); script
The code block executed by the while statement, if calculated as true in the specified condition. If the condition becomes false
To stop execution and control the loop passed to the statement. The syntax of the while loop is as follows:
While (condition)
{
Code to be executed;
}
The code block symbol in the relevant declaration, but always tells PHP code in closed (Opening and Closing braces)
Clear which rows should pass through the loop.
A while LOOP is the most commonly used list with no known criteria and the number of iterations. For example:
While (there are still rows to read from a database)
{
Read in a row;
Move to the next row;
}
Let's take an example. The first example defines a loop starting with I = 0. The loop continues to run as long
Variable I is less than or equal to 10. I will add 1 to run each loop:
$ I = 0;
While ($ I <= 10) {// Output values from 0 to 10
Echo "The number is". $ I ."
";
$ I ++;
}
?>
Now, let's consider a more useful example: create a list of days, months, or years in the drop-down list. You can
Code for using this registration form, for example.
$ Month_array = array ("January", "February", "March", "0000l", "May ",
"June ",
"July", "August", "September", "October", "November ",
"December ");
Echo"";$ I = 1;While ($ I <= 31 ){Echo"". $ I ."";$ I ++;}Echo"";
Echo"";$ I = 0;While ($ I <= 11 ){Echo"". $ Month_array [$ I]."";$ I ++;}Echo"";
Echo"";USD I = 1900;While ($ I <= 2007 ){Echo"". $ I ."";$ I ++;}Echo"";
?>