-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12-loop.php
More file actions
47 lines (42 loc) · 1.17 KB
/
12-loop.php
File metadata and controls
47 lines (42 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>PHP Loops</h1>
<p>Loops are used to execute the same block of code again and again, as long as a certain condition is true.</p>
<?php
/*
while
do...while
for
foreach
*/
$time = 0;
echo "<h3>For Loop</h3>";
for($i = 1; $i <= $time; $i++) {
echo "បងសុំទោសលើកទី: ".$i."<br>";
}
echo "<h3>While Loop</h3>";
$i = 1;
while($i <= $time) {
echo "បងសុំទោសលើកទី: ".$i."<br>";
$i++;
}
echo "<h3>Do While Loop</h3>";
$i = 1;
do {
echo "បងសុំទោសលើកទី: ".$i."<br>";
$i++;
} while($i <= $time);
// បងសុំទោសលើកទី 1
// បងសុំទោសលើកទី 2
// បងសុំទោសលើកទី 3
// បងសុំទោសលើកទី 4
// បងសុំទោសលើកទី 1000
?>
</html>