Register|Login

Have a question? Click here to ask the community.

Tutorial 17 – For Loop

| In: 17. For Loop | 6,647 views

Video Tutorial


Video Source Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
//File Description: PHP For Loop
 
/*
for (initalize counter; evaluate condition; increment the counter) {
    execute this code
}
*/
 
//For Loop Example
for ($counter = 0; $counter <= 10; $counter++) {
    echo "Counter is now: $counter <hr />";   
}
 
// While Loop Example
$counter2 = 0; // initialize counter
while ($counter2 <= 10) { // evaluate condition
    echo "Counter2 is now: $counter2 <hr />"; 
    $counter2++; // increment the counter
}
 
?>

Comment Form

You must be logged in to post a comment.