-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathif.php
More file actions
53 lines (47 loc) · 1.19 KB
/
if.php
File metadata and controls
53 lines (47 loc) · 1.19 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
<?php
$a = 7;
$b = 7;
$c = 3;
// Add an else clause to the next two statemets
if ($a < $b) {
// output the appropriate result
echo "$a is less than $b\n";
} else {
echo "$a is not less than $b\n";
}
if ($b > $a) {
// output the appropriate result
echo "$b is greater than $a\n";
} else {
echo "$b is not greater than $a\n";
}
// Shorten the next 2 statements into an if/else
if ($b >= $c) {
// output the appropriate result
echo "$b is greater than or equal to $c\n";
} else {
echo "$b is less than $c\n";
}
if ($b <= $c) {
// output the appropriate result
echo "$b is less than or equal to $c\n";
} else {
echo "$b is greater than $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) {
// output the appropriate result
echo "$b is equal to $c\n";
} else if ($b === $c) {
// output the appropriate result
echo "$b is identical to $c\n";
} else if ($b != $c) {
// output the appropriate result
echo "$b is not equal to $c\n";
} else if ($b !== $c) {
// output the appropriate result
echo "$b is not identical to $c\n";
}
?>