[英]How can I echo w/ PHP , custom css directives into this css file?
Make your server parse CSS files as PHP and then add this at the top of your CSS files: 使服务器将CSS文件解析为PHP,然后将其添加到CSS文件的顶部:
<?php Header ("Content-type: text/css");?>
I believe the .htaccess line to make CSS files run through PHP is: 我相信使CSS文件通过PHP运行的.htaccess行是:
AddType application/x-httpd-php .css
Warning! 警告! Opera will try to cache php files with css content types.
Opera将尝试缓存具有CSS内容类型的php文件。 It is recommended that in addition to declaring a text/css content type, you include the entire following code at the beginning of your CSS file:
建议除了声明文本/ css内容类型之外,还应在CSS文件的开头包含以下完整代码:
<?php
header("Content-type: text/css");
//http://www.thinkvitamin.com/features/webapps/serving-javascript-fast
//required so Opera does not cache this file
# 'Expires' in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
# Always modified
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
# HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
# HTTP/1.0
header("Pragma: no-cache");
?>
To remind myself that these are css files, I maintain the following naming convention: 为了提醒自己,这些是css文件,我维护以下命名约定:
file-name.css.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.