简体   繁体   中英

How can I echo w/ PHP , custom css directives into this css file?

http://www.easysavannah.com/myspace1/template/default/css.css我现在使用此程序对Myspace类型的网站进行Beta版测试>

Make your server parse CSS files as PHP and then add this at the top of your CSS files:

<?php Header ("Content-type: text/css");?>

I believe the .htaccess line to make CSS files run through PHP is:

AddType application/x-httpd-php .css

Warning! Opera will try to cache php files with css content types. 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:

<?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:

file-name.css.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM