-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconditionals.php
More file actions
67 lines (53 loc) · 1.15 KB
/
conditionals.php
File metadata and controls
67 lines (53 loc) · 1.15 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
<?php
/*
Coparison Operators
==
===
<
>
<=
>=
!=
!==
*/
$num = 4;
if($num == 5){
echo '5 passed';
}elseif($num == 6){
echo '6 passed';
}else{
echo 'did not pass';
}
#Nesting if
$num = 5;
if($num>4){
if($num<10){
echo "$num passed";
}
}
/*
Logical Operators
and &&
or ||
xor
*/
if($num > 4 AND $num < 10){
echo "$num passed";
}
#switch
$favColor = 'red';
switch($favColor){
case 'red':
echo 'Your Favorite Color is red';
break;
case 'blue':
echo 'Your Favorite Color is blue';
break;
case 'green':
echo 'Your Favorite Color is green';
break;
default:
echo 'Your Favorite Color is somthig else';
break;
}
?>