Php learning loop structure implementation code. For more information, see.
Php learning loop structure implementation code. For more information, see.
The Code is as follows:
/* Loop Structure
* 1. while Loop
* While (expression)
*{
* Loop body; // execute repeatedly until the expression is false.
*}
* 2. do-while loop
* 3. for Loop
*
* There are two types of loops based on different cyclic conditions.
*
* One Type: Counting loop ()
* Another type: Conditional loop (usually while do-while)
*
*
*
*/
// While usage
/* $ Num = 0;
While ($ num <100)
{
Echo "output result {$ num }";
$ Num ++;
}*/
// While output table
Echo'
';Echo'
Use the while output table
';$ I = 0;While ($ I <1000){// Change a row every 10 timesIf ($ I % 10 = 0){If ($ I % 20 = 0){$ Bg = "# ffffff ";}Else{$ Bg = "# cccccc ";}Echo'
'; // The color of the output line}Echo'
'. $ I .' | ';$ I ++;If ($ I % 10 = 0){Echo'
';}}Echo'
';
?>