PHP Control Constructs
- Looping.
- Loop bodies use brackets under same rules.
- While loop: repeat some code while a test is true
- Test first.
- If true run the body then test again.
- May run zero times if test is initially false.
- Test may become false anywhere within the body, but body will
finish anyway.
- For loop: An extended while loop.
- Initialize a variable
- Run while the test is true.
- Incrementing each iteration.
- Do loop: A while loop, but must always run the first iteration.
[ PHP Loops Source ]
- Foreach
- Repeat some code for each member of an array.
- Form for values, and another for key and value.
[ PHP Foreach Statement Source ]
- Some examples.
- Grid: [ 5x7 Source ]
[ 10x8 ]
- Dot row
- This one creates links that send a parameter back to itself.
- This creates an interactive page with a server turn-around.
- [ Row of colors Source ]