-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
70 lines (48 loc) · 858 Bytes
/
index.php
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
<?php
// variable declaration
$temp_storage = 'Hello';
// conditional statements
if($temp_storage == 'Hello') echo 'condition is true';
else echo 'condition dose not true';
// concatenation
$v1 = "Hello";
$v2 = 'World';
echo $v1.' '.$v2.'<br>';
// Defined global variable
define('VAR1', 'Defined variable');
echo VAR1;
// arithmetic operators
$v1 = 5;
$v1 = $v1 + 2;
$v1 += 5;
echo $v1++;
echo --$v1;
echo $v1;
// for loop
for($i=1; $i<=100; $i+=5){
echo $i.'<br>';
}
// while loop
$i=1;
while($i<=100) {
echo $i.'<br>';
$i+=5;
}
// do while loop
$i = 101;
do{
echo $i.'<br>';
$i+=5;
} while($i<=100);
// Write a function
function add($num1, $num2){
return $num1 + $num2;
}
$t1 = add(5, 5);
echo $t1;
echo '<br>';
echo add(15, 5);
echo '<br>';
$t3 = add(6, 9);
if($t3 != 14) echo 'variable value is not equal to 14';
?>