Re: variables in CSS in PHP question/problems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Surf directly to your CSS URL and see what happens.

There are several possibiliies:
#1.
Your CSS has <?php ... ?> in its output, because you have not
convinced your web-server to run your CSS file through PHP to compute
the dynamic result.

You need something like this in .htacces:

<File whatever.css>
  ForceType application/x-httpd-php
</File>


whatever.css should be your CSS filename.

application/x-httpd-php is the default, but your webhost/httpd.conf
could use ANY mime type it felt like using there.  Read your
httpd.conf to figure this out if it's not the usual (above)

Once you get your web-server to pass your CSS through PHP and spit out
the dynamic CSS that you desire...

#2.
Your CSS has what you expect in it, but the browser thinks it's an
HTML document, and shows it as such.

This is because in php.ini your default Content-type is text/html.

But when you spit out your CSS, with the PHP dynamic content to it,
you need this at the very tip-top:

<?php
  header("Content-type: text/css");
?>

so that the BROWSER knows that you are sending CSS.

Note:
Some browsers may *ignore* the Content-type and "assume" from the .css
URL that it is CSS.  That's pretty broken, but they are trying to
"help" the web designers who can't configure their web server to send
the right Content-type for .css files.

#3
Once you have done all that, there is a VERY good chance that your
browser (especially IE) has cached the old .css file...

You may need to hold the control-key and click on the "Refresh"
button, or hold down SHIFT (or is it ALT?) and control-R for "reload"
in Mozilla-based, or ...

Actually, if you surf directly to the CSS, and reload that, as in #1
and #2 above, the browser should do the right thing.

But the problem remains that as you change your CSS dynamically, if
the browser is caching the OLD CSS...

So now you may need some no-cache and Last-modified headers as well.

#4
You are on your own to fix the 50-line OOP mess to solve a 1-line
problem... :-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux