【问题标题】:CSS doesn't want to include in fileCSS不想包含在文件中
【发布时间】:2019-12-06 05:37:09
【问题描述】:

我正在建立一个 xampp php 网站,并为网站自动创建 css(如果创建了名为 xyz.php/html 的网站,那么也会创建一个 css)。不幸的是,css 不想包含在使用 php echo 和 html 标签的网站中。没有错误。

在 style.php 中:

$arr = explode("/",$_SERVER['PHP_SELF']);
$style = "";
foreach ($arr as $key){
    if(strpos($key, ".php")){
        $style = str_replace(".php", "style.css", $key);
    }
}
if($fp = fopen($_SERVER['DOCUMENT_ROOT']."/TestPHP/".$addr,"wb+")){
    fwrite($fp,"body{background-color:#666;}");
    fclose($fp);
}
echo $addr = "lib/require/styles/".$style;
echo '<link href="'.$addr.'" rel="stylesheet">';

在 index.php 中:

require_once 'lib/require/php/styles.php';

【问题讨论】:

  • styles.php的完整路径是什么
  • require_once 'lib/require/php/styles.php';

标签: php html css xampp


【解决方案1】:

那是因为唯一的 HTML(正如我在您的代码中看到的)除了样式,没有头部,没有正文之外没有其他任何东西......为什么不直接将 HTML 粘贴到文件中而不是制作PHP 回显它?

【讨论】:

    猜你喜欢
    • 2019-06-14
    • 1970-01-01
    • 2011-03-19
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多