Register|Login

Have a question? Click here to ask the community.

Tutorial 16 – Do While Loop

| In: 16. Do While Loop, Basic PHP Tutorials | 6,083 views

Video Tutorial


Video Source Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
//File Description: PHP Do While Loop
 
/*
do {
    this at least once (execute this code)
} while (this condition is true);
*/
 
// Example
$counter = 51; // keeps up with the current count in loop
 
do {
	$answer = 3 * $counter; // perform calculation 
	echo "3 * $counter = $answer <hr />"; // 3 * 1 = 3
	$counter++; // add 1 to counter
} while ($counter <= 50);
?>

Comment Form

You must be logged in to post a comment.