Page 1 of 1

Calling PHP from .css files .....

Posted: Wed Apr 06, 2005 6:13 pm
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

Posted: Wed Apr 06, 2005 7:03 pm
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.

hmm

Posted: Thu Apr 07, 2005 12:10 am
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

Posted: Thu Apr 07, 2005 4:28 am
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 ;)

Posted: Sat Apr 09, 2005 12:57 pm
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.