虽然file_existis返回true,但CSS没有显示在php中

时间:2015-12-23 17:04:34

标签: php css

出于某种原因,我的css没有出现。

  <link rel="stylesheet" href="public/css/style.css">

问题 那么什么会导致CSS显示空白?

设置 我正在使用Arch Linux并且已经设置了一个带有虚拟主机的LAMP。我的vhost文件DocumentRoot设置为/ home / codeamend / Projects / www / quick-mvc /,这是我的树打印的地方。 我的所有权限都已正确设置,拥有代码为“http”的所有者775:http

有用的输出 我也在链接标记

上方运行了这个
    <?php echo (file_exists('public/css/style.css') ? "true" : "false"; ?>

返回 true。

  echo __DIR__;

/家庭/ codeamend /项目/ WWW /快速MVC /视图/布局/默认

  echo "Request scheme: " . $_SERVER['REQUEST_SCHEME'];

HTTP

  echo "Request host: " . $_SERVER['HTTP_HOST'];

快速MVC

我的布局

http://quick-mvc/
    ├── controllers
    │   ├── front.php
    │   └── rear.php
    │
    ├── index.php <------- home file
    │
    ├── libs
    │   ├── Bootstrap.php
    │   ├── Controller.php
    │   └── View.php
    ├── public
    │   ├── css
    │   │   └── style.css
    │   └── js
    │       └── script.js
    └── views
        ├── front
        │   └── index.php
        ├── layouts
        │   └── default
        │       ├── footer.php
        │       └── header.php
        └── rear
            └── index.php

2 个答案:

答案 0 :(得分:0)

哈哈哈,它和我发生了很多次......:P(不是在笑你)

始终使用css

中的type和rel in link标记
<link type="text/css" rel="stylesheet" href="public/css/style.css">

答案 1 :(得分:0)

根据你的结构,试试这个

<?php echo file_exists(__DIR__.'/public/css/style.css') ? $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . "/public/css/style.css" : ""; ?>

如果仍然无效,请尝试查找.htaccess文件以获取正确的权限(如果服务器是Apache)

相关问题