This is a re-post from this article.
A few years back, I was looking for a way to embed PHP variables in a CSS file. Anyway, the author did it like this:
<link href="style.php" rel="stylesheet" media="screen" /> |
And the CSS part…
<?php /*** set the content type header ***/ header("Content-type: text/css"); /** set the paragraph color ***/ $para_color = '#0000ff'; /*** set the heading size ***/ $heading_size = '2em'; /*** set the heading color ***/ $heading_color = '#c0c0c0'; ?> p{ color: <?php echo $para_color; ?>; font-weight: bold; font-size: 1.2em; text-align: left; } h1{ color: <?php echo $heading_color; ?>; font-size = <?php echo $heading_size; ?>; text-align: centre; } |