![]() |
PHP in CSS
How can I use some PHP code in my CSS files?
In my .htaccess file, I tried: AddType application/x-httpd-php .css and AddHandler application/x-httpd-php5 .css But it didn't work. :-( What am I doing wrong? |
I don't understand the question.
CSS is generally a completely separate entity from PHP. If you'd like to actively modify CSS code, you should look into javascript solutions, and you can even use PHP before/after the javascript command. |
Not a PHP issue.
Make sure you have AllowOverride set in httpd.conf to include FileInfo as well. If using the mod_mime.c and AddType isn't working, than checking the httpd.conf for the AllowOverride configurations is where to start. You also don't really need to do it. Client developers could verify, but best I know browsers don't do any extension verification on an imported stylesheet. Assuming that's correct, you can successfully import a .php file without needing to add css to a parsable type. |
Quote:
text/css the file extension doesn’t matter.note: Apache automatically assigns text/html to PHP files, if not overwritten in the PHP script. |
Yep, good to note the content type. That's easy to fix in PHP of course; simply add
header('Content-type: text/css'); to the first instruction for PHP. |
You might also look into LESS CSS, depending on what you're needing. I find it a much cleaner way to manage macros and such in CSS than using PHP.
Dave |
| All times are GMT +1. The time now is 08:30 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.