I'm fairly new to PHP and I need to know how to display a file as an image. For example, opening http://example.com/script.php will show an image.
My reasoning for this is I need to put it in the src
attribute of <img>
. I want the image to change depending on what time it is.
I currently have 3 images to cycle between.
What I currently have:
<?php
$w = date('W'); # week
$d = date('N'); # day
$t = date('G'); # time
dealWithTime($d);
function dealWithTime(day) {
if (day == 1) {
# Monday
if ($w == 13) {
# Week 13
} else if ($w == 14) {
# Week 14
if ($t >= 0 && $t <= 6) {
# Image = 1.png
} else if ($t > 6 && $t <= 10) {
# Image = 2.png
} else if ($t > 10 && $t <= 14) {
# Image = 3.png
} else if ($t > 14 && $t <= 18) {
# Image = 1.png
} else if ($t > 18) {
# Image = 2.png
}
}
} else if (day == 2) {
# Tuesday
} else if (day == 3) {
# Wednesday
} else if (day == 4) {
# Thursday
} else if (day == 5) {
# Friday
} else if (day == 6) {
# Saturday
} else if (day == 7) {
# Sunday
}
}
?>