dongshi949737 2014-12-29 18:54
浏览 51
已采纳

浏览器忽略php打印的css

I have a stylesheet link that looks like below:

<link rel="stylesheet" href="/example/get_page.php?location=bla.css" id="main_ss" />

get_page.php just gets a URL using file_get_contents():

if (isset($_GET['location'])) {  
    echo file_get_contents('/example/styles/' . $_GET['location']);
}

I can see that the stylesheet file is being fetched properly (for example the text of the file is showing in firebug when I expend the link tag) but for some reason it is ignored by the browser. If I just fetch the CSS file directly of course everything works.

The code can be seen here: www.specman-verification.com/example/bla.html

Any leads? I'm at loss here.

  • 写回答

3条回答 默认 最新

  • doujiang6944 2014-12-30 09:37
    关注

    Add the Content-type header like this (do this before you output anything):

    header("Content-type: text/css");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制