【问题标题】:Is it possible to add CDN on HTML via a PHP include?是否可以通过 PHP 包含在 HTML 上添加 CDN?
【发布时间】:2019-08-16 20:46:28
【问题描述】:

我正在为家庭作业创建一个网站,它将有多个页面。我正在使用引导程序 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 html bootstrap-4 cdn


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

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

      并在您的&lt;head&gt; 部分中调用该文件,例如..

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

      【讨论】:

        猜你喜欢
        • 2016-06-01
        • 1970-01-01
        • 1970-01-01
        • 2014-08-16
        • 2012-05-08
        • 2019-02-18
        • 1970-01-01
        • 2012-08-26
        相关资源
        最近更新 更多