-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathloops.php
More file actions
46 lines (39 loc) · 820 Bytes
/
loops.php
File metadata and controls
46 lines (39 loc) · 820 Bytes
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
<?php
/**
* Topic: Loops
* Author: Muhammad Afzal
* Class: e-Rozgaar Batch#11
* Date: 6th Jan 2021
*/
//Define Constant
define("BR","<br />");
//For Loop
for($a=1;$a<=10;$a++){
echo $a.BR;
}
//I want to Print Only Even Numbers
// From 1 to 20
echo "Even Numebrs".BR;
for($a=0;$a<=20;$a+=2){
echo $a.",";
}
//Loop in Revers
echo BR."loop in Reverse".BR;
for($a=10;$a>=0;$a--){
echo $a.",";
}
echo "While Loop".BR;
//While Loop
$counter=0;
while($counter<10){
echo $counter.BR;
++$counter;
}
echo "Do-While Loop".BR;
//do-While Loop
$counter=0;
do{
echo $counter.BR;
++$counter;
}while($counter<10)
?>