如何在CSS中包含PHP代码? [英] How to include PHP code in CSS?
本文介绍了如何在CSS中包含PHP代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个脚本,我需要在CSS样式表中包含PHP代码。但是当我尝试添加PHP代码在我的CSS文件没有发生任何事情!是否可以?
解决方案
重命名您的CSS文件以 .php
,
styles.css - > styles.php
但是,我怀疑你真的需要在一个CSS文件中有PHP代码。 / p>
与下面的注释相比,请放心
<?php header(Content-type:text / css); ?>
在文件顶部。
I have a script, and I will be needing to include PHP code in the CSS stylesheet. But when I try adding PHP code in my CSS file nothing occurs! Is it possible?
解决方案
Rename your CSS file to end in .php
,
styles.css -> styles.php
However, I doubt that you really need to have PHP code in a CSS file.
Good point from the comments below, place
<?php header("Content-type: text/css"); ?>
at the top of the file.
这篇关于如何在CSS中包含PHP代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文