Concept

How are while loops structured and styled in PHP?

ComputerScienceOne / While Loops

"PHP supports while loops, for loops, and do-while loops using the keywords while, for, and do (along with another while). Continuation conditions for loops are enclosed in parentheses, (...) and blocks of code associated with the loop are enclosed in curly brackets. Code Sample 39.1 contains an example of a basic while loop in PHP. As with conditional statements, our code style places the opening curly bracket on the same line as the while keyword and continuation condition. The inner block of code is also indented and all lines in the block are indented to the same level. In addition, the continuation condition does not contain a semicolon since it is not an executable statement. What happens is:\n\n1 $i = 1; //Initialization\n\n2 while($i <= 10) { //continuation condition\n\n3 //perform some action\n\n4 $i++; //iteration\n\n5 }\n\nCode Sample 39.1.: While Loop in PHP 527"

Related Ideas

How are while loops structured and styled in PHP? | ComputerScienceOne | Bifalgorithm | Bifalgorithm