They're independent technologies. Why would you want to use PHP in CSS?
The best I can think of is for some kind of conditional formatting, for which you may use PHP with CSS just as you would use PHP with HTML. PHP effectively doesn't know the difference between HTML and CSS -- it's all just text.
Renegade posted this at 06:30 — 31st October 2004.
I am thinking of conditional formatting, and maybe some stuff where I have to have ten buttons, all the same code other than background color. I could do some type of for loop.
KeithMcL posted this at 14:04 — 4th November 2004.
Dragon of Ice wrote: I am thinking of conditional formatting, and maybe some stuff where I have to have ten buttons, all the same code other than background color. I could do some type of for loop.
Yeah, it would validate. This is how server-side theme switchers, "currently selected" nav elements and such are done.
PHP doesn't know what it's printing out, as it's only text as far as it's concerned. The validator doesn't know about any PHP or server-side code, as it's only the output it can see.
syawilim posted this at 01:07 — 1st November 2004.
You could use PHP to generate the buttons with classes assigned as you would normally do with HTML...you would not need to do anything differant with your CSS.
My site for example the main menu and the footer are generated by the same PHP script....the only problem I have at the moment with it is that it dose not validate because I am using an id tag for the active link and am having a little trouble getting it to work with a class tag....if anyone has any ideas.
There are no stupid questions, only stupid people!
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.
Abhishek Reddy posted this at 02:54 — 31st October 2004.
He has: 3,348 posts
Joined: Jul 2001
They're independent technologies. Why would you want to use PHP in CSS?
The best I can think of is for some kind of conditional formatting, for which you may use PHP with CSS just as you would use PHP with HTML. PHP effectively doesn't know the difference between HTML and CSS -- it's all just text.
Renegade posted this at 06:30 — 31st October 2004.
He has: 3,022 posts
Joined: Oct 2002
I have seen people do the following:
<link rel="stylesheet" type="text/css" href="style.php" />
'I haven't tried this out for myself though. Another way of doing this would be to have the CSS in the tags.
Abhishek Reddy posted this at 08:40 — 31st October 2004.
He has: 3,348 posts
Joined: Jul 2001
Or you could have PHP print the path to your chosen stylesheet:
<?php
echo \"<link rel=\\"stylesheet\\" type=\\"text/css\\" href=\\"\" . $path . \"\\" />\"
?>
Dragon of Ice posted this at 13:40 — 31st October 2004.
He has: 578 posts
Joined: Jun 2004
I am thinking of conditional formatting, and maybe some stuff where I have to have ten buttons, all the same code other than background color. I could do some type of for loop.
KeithMcL posted this at 14:04 — 4th November 2004.
He has: 176 posts
Joined: Oct 1999
This article might be some use to you:
http://www.sitepoint.com/article/css-simple-style-switcher
Dragon of Ice posted this at 15:44 — 31st October 2004.
He has: 578 posts
Joined: Jun 2004
Also, do you think it would still validate?
Abhishek Reddy posted this at 00:21 — 1st November 2004.
He has: 3,348 posts
Joined: Jul 2001
Yeah, it would validate. This is how server-side theme switchers, "currently selected" nav elements and such are done.
PHP doesn't know what it's printing out, as it's only text as far as it's concerned. The validator doesn't know about any PHP or server-side code, as it's only the output it can see.
syawilim posted this at 01:07 — 1st November 2004.
He has: 93 posts
Joined: Jun 2004
You could use PHP to generate the buttons with classes assigned as you would normally do with HTML...you would not need to do anything differant with your CSS.
My site for example the main menu and the footer are generated by the same PHP script....the only problem I have at the moment with it is that it dose not validate because I am using an id tag for the active link and am having a little trouble getting it to work with a class tag....if anyone has any ideas.
There are no stupid questions, only stupid people!
slickfish
web site design, production and maintenance for small business
www.justapickle.com
Blogging for the socially conscious
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.