[thelist] Using PHP to write CSS

Andy Warwick mailing.lists at creed.co.uk
Mon May 20 15:25:01 CDT 2002


Burhan Khalid wrote:

> Hello all :
> . . . is there a way to have PHP
> scan a file for a place holder and then replace it with something else? I'm
> looking for a greymatter-like {{something}} type solution.

Burhan

If you are on Apache server you can add the following line to your .htaccess
file and PHP will directly parse your CSS files as well; there will be a
performance hit, but I suspect it will be less than loading a file into a
variable then writing it back.

    AddHandler application/x-httpd-php .css

That way you can simply transfer your PHP code into the included stylesheet and
parse it in situ.

I use this trick for including images in the background of pages with full
paths:

body
{
    background: #f9f9f9 url(<?php echo "http://".SITE_URI ; ?>watermark.gif);
}

HTH

Andy W



More information about the thelist mailing list