Skip to content

Commit 2478c27

Browse files
committed
Added greeting PHP example
1 parent 46d67a2 commit 2478c27

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

week-3-if/greeting.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>PHP Greeting</title>
8+
</head>
9+
<body>
10+
11+
<h1>PHP Greeting</h1>
12+
13+
<?php
14+
15+
/*
16+
Monday - Do you have a case of the Mondays?
17+
Friday Afternoon - It's almost the weekend!
18+
Before Noon - Have a good morning!
19+
After Noon - Have a good day!
20+
Weekend - It's the weekend!!!
21+
*/
22+
23+
$day = date('w');
24+
$hour = date('G');
25+
26+
$day = 5;
27+
$hour = 13;
28+
29+
echo "<p>The current day is $day and the current hour is $hour.</p>";
30+
31+
// echo '<p>String: '.is_string($day).'</p>';
32+
33+
if($day == 1)
34+
{
35+
echo '<h2>Do you have a case of the Mondays?</h2>';
36+
}
37+
elseif($day == 0 or $day == 6)
38+
{
39+
echo '<h2>It\'s the weekend!!!</h2>';
40+
}
41+
elseif($day == 5 or $hour >= 12)
42+
{
43+
echo '<h2>It\'s almost the weekend!</h2>';
44+
}
45+
elseif($hour < 12)
46+
{
47+
echo '<h2>Have a good morning!</h2>';
48+
}
49+
else
50+
{
51+
echo '<h2>Have a good day!</h2>';
52+
}
53+
54+
?>
55+
56+
</body>
57+
</html>

0 commit comments

Comments
 (0)