Based on the PHP headers article, Lets write a simple dynamic css file that will change the background to blue if it is monday.
First you would have the following php snippet
header('Content-Type: text/css'); // this tells apache or web server to output the following as a css txt file
Proceed to write css as you usually would.
<?php
header('Content-Type: text/css'); // this tells apache or web server to output the following as a css txt file
?>
body
{
<?php
if (date('U') == 'Mon')
{
echo 'background-color:blue;';
}
else
{
echo 'background-color:white;';
}
?>
font-size:10px;
}
First thing you will notice is that our file is called screen.php instead of screen.css. This is so when the browser calls the file, apache or IIS knows to render the file against a PHP parser.
Now all we need to do is include it into our html file.
<link href="screen.php" rel="stylesheet" type="text/css" media="screen,projection" />