Register|Login

Have a question? Click here to ask the community.

Tutorial 15 – While Loop

| In: 15. While Loop | 8,419 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
<?php
//File Description: PHP While Loop
 
/*
while (this condition is true) {
    execute this code
}
*/
 
// Example
 
$counter = 1; // keeps up with the current count in loop
 
while ($counter <= 25) {
    $answer = 3 * $counter; // perform calculation
    echo "3 * $counter = $answer <hr />"; // 3 * 2 = 6
    $counter++; // add 1 to counter
}
 
echo "Welcome to The PHP Basics <br>";
?>



1 Response to Tutorial 15 – While Loop

Avatar

Per-Johan

February 19th, 2017 at 2:03 pm

What is the best way to kill an endless while loop? I tried making one to see what happened, and I ended up having to kill the processes in windows.

Comment Form

You must be logged in to post a comment.