-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathif.php
48 lines (39 loc) · 1.04 KB
/
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
46
47
48
<?php
$a = 5;
$b = 10;
$c = '10';
// Shorten the next 2 statements into an if/else
if ($a < $b) {
echo "$a is less than $b" . PHP_EOL;
} else {
echo "$b is greater than $a" . PHP_EOL;
}
// Shorten the next 2 statements into an if/else
if ($b >= $c) {
// output the appropriate result
echo "$b is greater then or equal to $c\n" . PHP_EOL;
}
else {
// output the appropriate result
echo "$b is less than or equal to $c\n" . PHP_EOL;
}
// 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) {
// output the appropriate result
echo "$b is equal to $c" . PHP_EOL;
}
else if ($b === $c) {
// output the appropriate result
echo "$b is identical to $c" . PHP_EOL;
}
else if ($b != $c) {
// output the appropriate result
echo "$b is not equal to $c" . PHP_EOL;
}
else if ($b !== $c) {
// output the appropriate result
echo "$b is not identical to $c" . PHP_EOL;
}
?>