Using PHP as a CSS file?

2019-06-20 07:52发布

How would I go about using PHP as a CSS file. I have just included it as a normal css file, but it fails to work in Google Chrome.

2条回答
萌系小妹纸
2楼-- · 2019-06-20 08:06

Try adding

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

in first line of your stylesheet.php

查看更多
做自己的国王
3楼-- · 2019-06-20 08:22

You have to tell the browser that it is a CSS-file and not a HTML-file, write the following before any output:

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

See: http://www.barelyfitz.com/projects/csscolor/

查看更多
登录 后发表回答