How to change background color using php

Last updated on January 26th, 2022 at 09:55 am

Click to rate this tutorial!
[Total: 2 Average: 3]

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

Click to rate this tutorial!
[Total: 2 Average: 3]

Leave a Reply

Your email address will not be published.