【发布时间】:2018-05-09 06:50:28
【问题描述】:
我使用 php、html 和 css 创建了一个网站。
我使用<link rel="stylesheet" src="main.css"> 将 css 文件调用到 html 文档,但是当我使用 php 编写/回显/打印"<link rel="stylesheet" src="main.css">" 时,即使在控制台上未检测到 css 也未加载.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><?php $this->actn->getAction("pageTitle"); ?></title>
<?php
if(isset($preq[0]) && $preq[0] != "report" && $preq != "action") {
switch($preq[0]) {
default:
echo "<link rel=\"stylesheet\" src=\"".$purl."source/lib/css/main.css\"> \n";
echo "<link rel=\"stylesheet\" src=\"".$purl."source/lib/css/functional.css\"> \n";
echo "<link rel=\"stylesheet\" src=\"".$purl."source/lib/css/header.css\"> \n"; break;
}
} else {
return null;
} ?>
</head>
<body>
<div class="container">
<?php $this->sect->getSection(); ?>
</div>
</body>
</html>
the console that doesn't show anything
注意:我使用的是 php 7.0.13
【问题讨论】:
-
什么是 $preq ?什么是 $purl ?它没有在你的脚本中定义
-
您是否也检查过控制台中的元素?我的意思是生成的代码......如果css文件的链接标签没有嵌入lr,这至少会给你一个想法。
-
你确定你的 if 条件 if(isset($preq[0]) && $preq[0] != "report" && $preq != "action") 是真的吗?只需在 switch case 之前回显一些值以检查它
-
你可以尝试在 if 语句 prev 'action' 中写 $preq[0] 吗?
-
$preq from explode("/", str_replace("index.php", "", $_SERVER['QUERY_STRING']));