Web development tip - Showing different image for each day of the week in our sites
We can display different images in our site by using the following script.
This PHP script will get the day of the week from the server date and then display an image (jpg or gif) to match.
Example
<?php
/*
* Note : Image names must be like Monday.gif, Tuesday.gif etc
*/
// Specify the location of the directory, where we can have our images
$image_dir = “images/dayimage”;
// Fetch image name from date() function
$today_img = date(’l');
if (file_exists($image_dir.”/”.$today_img.”.gif”)) {
echo “<img src=\”$image_dir/”.$today_img.”.gif\”>”;}
?>
