-
Notifications
You must be signed in to change notification settings - Fork 0
/
if.php
45 lines (32 loc) · 802 Bytes
/
if.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
<?php
$a = 5;
$b = '35';
$c = '35';
// Add an else to the next two statments.
if ($a < $b) {
echo "$a is less than $b\n";
} else {
echo "$a is greater than $b.\n";
}
if ($b > $a) {
echo "$b is greater than $a\n";
} else {
echo "$b is less than $a.\n";
}
// Shorten the next 2 statements into an if/else
if ($b >= $c) {
echo "$b is greater or equal to $c\n";
} else {
echo "$b is less than or equal to $c\n";
}
// combine the next 4 conditionals into
// one if/else/elseif block that checks in order for:
// identical, equal, not identical, not equal
if ($b == $c) {
echo "$b is equal to $c\n";
} elseif ($b != $c) {
echo "$b is not equal to $c\n";
} elseif ($b === $c) {
echo "$b is identical to $c\n";
}
?>