Follow:  Follow PHPExercises on Twitter  Follow us on Facebook

Control Structures - Loops and Conditional Statements

Try these exercises to test your skills with loops. Do...while, For, and While loops are all represented, as well as the various flavors of If statements. You will find some of more advanced versions of these structures in the Forms section.

The Control Structures section includes the following exercises:

#1: If-Else Statement
Use the if-else construct to print one of two statements to the browser, depending on whether the current month is August.
#2: Simple Loops
Create several nonsense outputs to practice using do...while, for, and while loops.
#3: Simple For Loop
Send a list of formulas to the browser, the squares of the numbers from 1-12, using a for loop.
#4: Nested For Loops
Using nested for loops, create a multiplication table for the numbers 1-7.

-- Home --