Ahhh I'm looking for things online and the tutorials, well, mostly forums, talk about @import and all this other stuff I really don't want to get into.
I want a file to process php. But it will act as a CSS file. Basically, I want this one php file to store various values to variables such as $fontColor, $backgroundColor, $fontSize, etc. And then this PHP/CSS hybrid file will call in variables like...
body
{
font-size:<?php echo $fontSize;?>;
}
And so on. Is this possible? I've seen a lot of tutorials for ASP, I think. If it is possible, I need to know what extension the file needs to be, and any other special instructions, such as in the linking process in the HTML file that calls the PHP/CSS Hybrid file.
Thanks in advance.you just have to send a css header at the top, if you are including it as a css file
<?php
$fontSize = "11px";
$fontColor = "#333";
header("Content-type: text/css");
?>
body {
font-size: <?php echo $fontSize; ?>;
color: <?php echo $fontColor; ?>;
}
you still save it as a .php file, but it will respond like a css file since you sent a css headerright, put the header up top, then include at the top whatever file is giving values to the variables, like so:<?
header("content-type:text/css");
include("../css_vars.php");
?>then name it with a .php extension, and link it like any other CSS file, except with the new extension.Oh cool, I didn't know you could do this. So you could use this with a database then?
Could you also use a query string and use get variables?
Hmm...opens up lots of possibilities.you can even do browser detection serverside and all that stuff. ive done that on a few websites.ahhh thankyou! it works.
I want a file to process php. But it will act as a CSS file. Basically, I want this one php file to store various values to variables such as $fontColor, $backgroundColor, $fontSize, etc. And then this PHP/CSS hybrid file will call in variables like...
body
{
font-size:<?php echo $fontSize;?>;
}
And so on. Is this possible? I've seen a lot of tutorials for ASP, I think. If it is possible, I need to know what extension the file needs to be, and any other special instructions, such as in the linking process in the HTML file that calls the PHP/CSS Hybrid file.
Thanks in advance.you just have to send a css header at the top, if you are including it as a css file
<?php
$fontSize = "11px";
$fontColor = "#333";
header("Content-type: text/css");
?>
body {
font-size: <?php echo $fontSize; ?>;
color: <?php echo $fontColor; ?>;
}
you still save it as a .php file, but it will respond like a css file since you sent a css headerright, put the header up top, then include at the top whatever file is giving values to the variables, like so:<?
header("content-type:text/css");
include("../css_vars.php");
?>then name it with a .php extension, and link it like any other CSS file, except with the new extension.Oh cool, I didn't know you could do this. So you could use this with a database then?
Could you also use a query string and use get variables?
Hmm...opens up lots of possibilities.you can even do browser detection serverside and all that stuff. ive done that on a few websites.ahhh thankyou! it works.