Last updated on November 23rd, 2022 at 01:43 pm

This is a very simple script which will dynamically change the background color of a webpage using php .Just copy and paste the script below.

In case if you missed it, we also have a script using Javascript that changes background color of a webpage.

<html>
<head>
<title>Background Colors change based on the day of the week</title>
</head>
<?php
//mistonline.in
$today = date("l");
print("$today");
if($today == "Sunday")
{
$bgcolor = "#FEF0C5";
}
elseif($today == "Monday")
{
$bgcolor = "#FFFFFF";
}
elseif($today == "Tuesday")
{
$bgcolor = "#FBFFC4";
}
elseif($today == "Wednesday")
{
$bgcolor = "#FFE0DD";
}
elseif($today == "Thursday")
{
$bgcolor = "#E6EDFF";
}
elseif($today == "Friday")
{
$bgcolor = "#E9FFE6";
}
else
{
// Since it is not any of the days above it must be Saturday
$bgcolor = "#F0F4F1";
}
print("<body bgcolor=\"$bgcolor\">\n");
?>

Check out the Demo

Leave a Reply

Your email address will not be published. Required fields are marked *