Chapter
For Loops
From ComputerScienceOne by Dr Chris Bourke
Concepts
- What happens when a while loop never increments its counter?
"In the while loop, we never increment the counter variable $i, the loop does nothing, and so the computation will continue on forever! It is valid PHP and will run, but obviously won’t work as intend
- How does a flag-controlled while loop determine when to stop?
"Another common use for a while loop is a flag-controlled loop in which we use a Boolean flag rather than an expression to determine if a loop should continue or not. Since PHP has built-in Boolean ty
- How are for loops structured in PHP?
"For loops in PHP use the familiar syntax of placing the initialization, continuation condition, and iteration on the same line as the for keyword. An example can be found in Code Sample 39.3. Semicol