Calling PHP from .css files .....

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
Ringo
Forum Newbie
Posts: 2
Joined: Wed Apr 06, 2005 5:53 pm

Calling PHP from .css files .....

Post by Ringo »

I'm trying to figure out how to call a php function from my .css file having little success. I can get block code to run from it but I have no clue how to get a function or call a function from it. Anyone here have any experienc with this process? Don't say you can run "include statements" from .css cuz you'd be wrong ....

Thanks in advance
Ringo
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

only ways to do it that I know of:
  • the CSS file would have to be parsed as PHP.
  • the call could only happen if you asked CSS to either import the file, or call an image that is actually a script.
A CSS file is pretty much like an HTML file. You can't call a php function spontaneously as php is (right now) processed solely on the server side of things. You'd have to do it through the facilities that are inherent to their system.
Ringo
Forum Newbie
Posts: 2
Joined: Wed Apr 06, 2005 5:53 pm

hmm

Post by Ringo »

Well there is a way to achieve that- I have sent it via PM. As I was saying Apache does see my .css file as a .php file and right now and I can run php scripts in my .css file. I've run several php scripts when I started testing it. Works great but .. my lack of php knowledge stops me from doing what I actually need to do. I've been digging for information on this subject but I guess most people think you cant run SSI from a .css file so I'm finding nothing. I know this isn't correct I do the same thing with .asp files to hide my code and a few other reasons. I'd be happy to share or exchange this information with someone that might be able to help.

Thanks for you post, I apreaciate it.

Ringo
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

there is no such as a .css file.

usually a webserver is only configured to phpparse files that end with .php
so 2 options; name the file blah.css.php or change the webserver configuration...


another issue is that a webserver is usually configured to send a different content-type header when a filename ends with .css. In the case your filename ends with .php it is possible that you need to send the correct header yourself..

for the rest they are both text files... and are both handled the same way ;)
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Here's another alternative: Import your CSS file, but in your HTML file (which is .php ) add a STYLE tag and make the necessary changes to the Style.
Post Reply