是否有可能通过PHP包含在HTML上添加CDN?



我正在创建一个家庭作业网站,它将有多个页面。我使用的是引导程序 4,对于每个页面,我必须在 HTML 的头部声明大量链接和脚本。

我的问题是,是否可以通过 HTML 或 PHP 包含添加单个链接,以便我可以对所有添加内容使用一行并在单个文件上编辑它们。

这就是我所拥有的

<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="stylesheet.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>

我想要这样的东西

<head>
<title> </title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="alltheotherlinksandscripts.php">
</head>

或者这个

<html>
<head>
<title></title>
<?php
include_once "alllinks.php";
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body> </body>
</html>

你可以。将标头放在单独的 php 文件中,您可以将其包含在所有文件中。

<head>
<?php include('header.php'); ?>
</head>

是的,您可以在一个文件中设置所有链接(js/css 库(,即alllinks.php

并在您的<head>部分中调用该文件,例如..

<head>
<?php include('alllinks.php'); ?>
</head>

最新更新