Source code for using CSS via PHP

The style sheet

The file name is mystyle.php.

<?php header("Content-type: text/css");
$color1 = "yellow";
if ($color1 == "yellow") $color2 = "lightgreen";
?>
body {background-color: <?=$color1?>;}
h2,h3,h4 {background-color: <?=$color2?>;}
#id1 {color: darkgreen; text-align: center; font-weight: bold}

The web page


<HTML>
<HEAD>
<link rel="stylesheet" type="text/css" href="mystyle.php">
</HEAD>
<BODY>
<h1>Welcome to my page!</h1>
Some text.

<h2 id="id1">I am still working on it...</h2>
Some more text...
</BODY>
</HTML>

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.