简体   繁体   English

Gzip压缩的css文件与php header,第一行ZC7A628CBA22E28EB167B5F5C6AE2A不起作用

[英]Gzip compressed css file with php header, first css line does not work

I am using gzip to compress my files so I need to add the following code to the top.我正在使用 gzip 压缩我的文件,所以我需要将以下代码添加到顶部。

ob_start("ob_gzhandler");
header("content-type: text/css; charset: UTF-8");
header("cache-control: must-revalidate");
header("expires: ".gmdate('D, d M Y H:i:s', time() + 1000)." GMT"); 

The problem is now that the first line of css code in my file does not work.现在的问题是我文件中的css代码的第一行不起作用。 eg例如

body{
  color: red;
  font-weight: bold;
}

using this the text would be bold but not red.使用这个文本将是粗体但不是红色。

Looking forward to an advice.期待一个建议。

Thanks in advance.提前致谢。

Edit:编辑:

From the comments, it turned out to be because:从评论来看,原来是因为:

the php code was inserting something into the css file. php 代码在 css 文件中插入了一些东西。

Probably either:可能是:


The font-color property does not exist. font-color属性不存在。

Use color: red instead.使用color: red代替。

If the text is indeed bold, then your CSS file is working, so there shouldn't be any more problems.如果文本确实是粗体,那么您的 CSS 文件正在运行,因此应该不会再有任何问题。

Although I think the last line of your PHP should be:虽然我认为你的 PHP 的最后一行应该是:

header("expires: ".gmdate('D, d M Y H:i:s', time() + 1000)." GMT"); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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