php - 如何使用php链接目录html文件中的引导文件
问题描述
我有一个头文件,其中包含指向 Bootstrap 和 jQuery 的链接。我在我的索引文件和我的常见问题解答文件中都包含了这个标题。索引文件中的链接工作正常,但 FAQ 文件中的引导链接不起作用。
我的头文件:
<head>
<title><?php echo $title; ?></title>
<link rel="stylesheet" type="text/css" href="./bootstrap.css">
<link rel="stylesheet" type="text/css" href=".././style.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
<link rel="stylesheet" href=".././../jQuery/jquery-ui.css">
<script type="text/javascript" src=".././../jQuery/jquery-3.4.1.js"></script>
<script type="text/javascript" src=".././../jQuery/jquery-ui.js"></script>
</head>
这是我的索引文件,其中包含标题:
<?php
$title = "Home page"; // (1) Set the title
include "header.php"; // (2) Include the header
?>
这是我的常见问题解答文件,其中还包括标题:
<?php
$title = "Home page"; // (1) Set the title
include "../header.php"; // (2) Include the header
?>
这是我的目录的快照:
解决方案
我认为这是因为您的相对路径,例如:
.././../jQuery/jquery-ui.js
您应该将它们更改为绝对路径,它可以解决您的问题
例如更改为这样的:
<script type="text/javascript" src="<?php echo __DIR__ ?>/../../jQuery/jquery-ui.js"></script>
推荐阅读
- javascript - Vue JS - 将变量设置为 vueObject.dataItem 并修改它也会修改 Vue 数据项
- multithreading - MPI 代码使用的 CPU 资源多于分配的资源(过度提交)
- spring-boot - 将 Lucene 查询字符串直接从用户传递到 QueryParser 是否安全?
- javascript - setInterval 内部的 Promise
- laravel - 让我的“welcome.blade.php”识别在我的 Nuxt.js 文件夹中导入的 Vue 时遇到问题
- ios - 如何给标签数组元素的值?
- php - 为什么我的数组项没有传递到 foreach PHP for GraphQL 上的函数?
- angular - 一个空数组被推送到 localStorage 而不是数据
- clojure - Clojure:将值设置为键
- javascript - 在 javascript 中将数组转换为对象,与 d3 输出相同