forked from assembler-institute/php-basics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconditionals.php
72 lines (57 loc) · 1.31 KB
/
conditionals.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
71
72
<?php
echo "<h1>Conditionals</h1>";
//Evaluate the current day
echo "<h3>Evaluate Current Day</h3>";
$currentDay = date("D");
var_dump($currentDay);
if ($currentDay === "Mon") {
echo "We are on Monday.";
}
echo "<br>";
//Evaluate the current month
echo "<h3>Evaluate Current Month</h3>";
$currentMonth = date("M");
var_dump($currentMonth);
if ($currentMonth === "Oct") {
echo "We are on Monday.";
} else {
echo $currentMonth;
}
//Evaluate the current minute
echo "<h3>Evaluate Current Minute</h3>";
$currentMinute = date("i");
var_dump($currentMinute);
if ($currentMinute < 10) {
echo "the current minute is less than 10";
} elseif ($currentMinute > 15) {
echo "the current minute is more than 15";
} else {
echo "does not meet any conditions";
}
//Switch
echo "<h3>Switch to evaluate the Current Day</h3>";
$day = date("D");
var_dump($day);
switch ($day) {
case "Mon":
echo "Today is Monday.";
break;
case "Tue":
echo "Today is Tuesday.";
break;
case "Wed":
echo "Today is Wednesday.";
break;
case "Thu":
echo "Today is Thursday.";
break;
case "Fri":
echo "Today is Friday.";
break;
case "Sat":
echo "Today is Saturday.";
break;
default:
echo "Today is Sunday.";
}
?>