如何导入/包括使用PHP代码而不是HTML代码的CSS文件? [英] How to import/include a CSS file using PHP code and not HTML code?

查看:189
本文介绍了如何导入/包括使用PHP代码而不是HTML代码的CSS文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经google了很多,但似乎我做错了。

I have googled a lot but it seems that I am doing something wrong.

我想这样做:

<?php
include 'header.php';
include'CSS/main.css';
...
?>

但是,我的页面打印CSS代码。

However, my page prints the CSS code.

注意:我想使用PHP来包含CSS文件,而不是使用

我也想将我的CSS文件重命名为一个PHP文件作为一些网站提到。

Note: I want to use PHP to include the CSS file, and not use I also do you want to rename my CSS file to a PHP file as some website mentioned.

任何线索?

非常感谢。

推荐答案

您将CSS代码作为文本包含在PHP页面中。为什么不以传统方式链接它?

You are including the CSS code as text in your PHP page. Why not just link it in the traditional fashion?

<link rel="stylesheet" href="CSS/main.css" type="text/css">

这篇关于如何导入/包括使用PHP代码而不是HTML代码的CSS文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆