Forum Moderators: coopster
Is there any special method that I have to use to get that to work? All of my variables are in a file that's being included before the CSS page is being referenced lije this:
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
But I'm also not able to parse ANY PHP in that CSS file, so I'm not sure how to set this up.
Thanks a lot in advance for any suggestions.
MK
The simplest way is to save the css file as
stylesheet.php and change the link to
link href="stylesheet.php" rel="stylesheet" type="text/css"
Alternatively you could solve that by telling your webserver that .css files are infact php scripts, but how you do that depends on what webserver you are using. I'd stick to the first method, as it's simple.
Sorry I missed that thread on this board. I'll check that out now. Thanks.
Also, I tried making the .css into a .php but didn't have any luck. I'll try that again just to see if I missed something. Also, I'm running Apache 2.x, so I probably will make it so that .css get parsed by PHP in the near future.
Thanks again guys.
<head>
<? $family = "Comic Sans MS";?>
<link href="stylesheet.php" rel="stylesheet" type="text/css" />
Now, if I have this line in stylesheet.php:
p { font-family: <? echo $family;?>; }
It's not changing anything to "Comic Sans MS". I can see that the $family varialbe isn't making it into the CSS page. How do I fix this? In reality I want to include a file full of variables and not just that one line, but once I get this figured out I guess the file will be a cinch to get working.
<? $family = "Comic Sans MS";?>
<link href="stylesheet.php" rel="stylesheet" type="text/css"/>
The stylesheet.php is fetched seperately by the browser, so there is no way for it to access variables that were set in a different page on the server. You need to put the
<? $family = "Comic Sans MS";?>
line into the stylesheet.php file, in order for it to work.
<? $family = "Comic Sans MS";?>
<link href="stylesheet.php?family=<?=$family;?>" rel="stylesheet" type="text/css"/>
I don't care for it, but I guess I'll just pass a variable to the CSS page that tells me where the file is at and include it that way. If it's the only way, then I'll have to live with it. :)
Thanks.