-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02_moreBasics.php
More file actions
103 lines (95 loc) · 2.27 KB
/
02_moreBasics.php
File metadata and controls
103 lines (95 loc) · 2.27 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!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>php tutu</title>
</head>
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
padding: 23px;
}
.container{
max-width: 80%;
background-color: grey;
margin: auto;
}
</style>
<body>
<div class="container">
<h1>Lets learn about php</h1>
<!-- This is a container -->
<p>Your party status is here </p>
<?php
$age=7;
if($age>18)
{
echo "You can go to party <br>";
}
else if($age==7){
echo "You are 7 years old <br>";
}
else{
echo "you can't go to party <br>";
}
$languages = array("Python","c++","php","NodeJs");
echo $languages[1] ;
echo count($languages);
// Loops in php
$a =0;
while($a<=10)
{
echo "<br>The value of a is: ";
echo $a;
$a ++;
}
//Iterating arrays using Loops in php
$a =0;
while($a< count($languages))
{
echo "<br>The value of languages is: ";
echo $languages[$a];
$a ++;
}
//do while
$a =0;
do
{
echo "<br>The value of languages is: ";
echo $languages[$a];
$a ++;
}while($a< count($languages));
//for loop
$a=200;
echo "<br>The value of a is: ";
echo $a;
for ($a=0; $a < 10; $a++) {
echo "<br>The value of a is: ";
echo $a;
}
//for each loop
foreach ($languages as $value)
{
echo "<br>The value from foreach is ";
echo $value;
}
//function
function print5(){
echo "<br>FIVE";
}
print5();
print5();
function print_num($n)
{
echo "<br> Your number is ";
echo $n;
}
print_num(45);
?>
</div>
</body>
</html>