SearchEngineChannel

Looking for somewhere to host your site? Browse our PHP web hosts section!

Home > PHP Scripts > Display a different image for each day of the week

Display a different image for each day of the week

Description

This PHP script will get the day of the week from the server date and then display an image (jpg or gif) to match.

The code


<?php


/**
 * Change the name of the image folder
 *
 * Images must be named Monday.gif, Tuesday.gif etc
 */

// Change to the location of the folder containing the images
$image_folder "images/days";

// You do not need to edit below this line

$today date('l');

if (
file_exists($image_folder."/".$today.".gif")) {
  echo 
"<img src=\"$image_folder/".$today.".gif\">";
}
else {
  echo 
"No image was found for $today";
}

?> 

Get the code

Download the file to your computer: Click here to get the file