Re: Using PHP with Style Sheets

From: Date: Mon, 19 Jan 2004 17:08:47 +0000
Subject: Re: Using PHP with Style Sheets
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-175041@lists.php.net to get a copy of this message
On Mon, Jan 19, 2004 at 11:08:29AM -0600, John Nichel wrote: > Freedomware wrote: > >OK, it looks like there are at least three ways to do this. I now have > >an original style sheet with a .css extension and copies with .php and > >.css.php extensions. > > > >All three style sheets have the following code at the top: > > > ><? > >header("Content-Type: text/css"); > >?> > > I would think that the above is going to cause problems. First, if you > have something like this... > > <html> > <head> > <title>My Page</title> > <?php include ( "style.php" ); ?> > </head> > .... > > and style.php has the header call in it, you're going to get an error. > Second, I don't know how much differently the browsers handle text/html > and text/css, but being that the header has to be sent before any output > to the browser, you will have changed the mime type of the whole document. I'm guessing that the .css file will be used in the traditional way: > <html> > <head> > <title>My Page</title> > <style type="text/css" href="path/to/stylesheet.css" /> > </head> Now, it's the browser that's fetching the .css file, so the header() call isn't a problem at all. The browser simply performs a separate request for that file, so its header() information is sent in response to that request. joel -- [ joel boonstra | gospelcom.net ]

« previous php.general (#175041) next »