forked from assembler-institute/php-basics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconditionals.php
More file actions
66 lines (52 loc) · 1.24 KB
/
conditionals.php
File metadata and controls
66 lines (52 loc) · 1.24 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
<?php
#Create a simple condition that evaluates whether the current day is Monday.
$currentDay = date('l');
$currentMonth = date('m');
if (date('l') === 'Monday') {
echo "We are on Monday";
}else{echo "Today is ". date("l");
}
echo "<br>";
#Create a simple condition that evaluates whether the current month is October.
if (date('m') === "October"){
echo "We are in October";
}else{
echo "Today is ". date('F');
}
echo "<br>";
#Create a double condition
$currentMinute = date('i');
if($currentMinute < 10){
echo "The current minute is less than 10";
}else if($currentMinute > 15){
echo "The current minute is more than 15";
}else{
echo "Does not meet any conditions";
}
echo "<br>";
#Create a switch type control structure to display a different message depending on the current day of the week.
$day = date('D');
switch($day){
case 'Sun';
echo "Today is Sunday";
break;
case 'Sat';
echo "Today is Saturday";
break;
case 'Fri';
echo "Today is Friday";
break;
case 'Thu';
echo "Today is Thursday";
break;
case 'Wed';
echo "Today is Wednesday";
break;
case 'Tue';
echo "Today is Tuesday";
break;
case 'Mon';
echo "Today is Monday";
break;
}
?>