gpt4 book ai didi

包含来自 Head 标记的脚本和资源的 PHP 文件(包含 PHP 的问题)

转载 作者:行者123 更新时间:2023-11-27 23:33:32 26 4
gpt4 key购买 nike

我正在尝试创建一个包含 scripts 的 PHP 文件, css链接和资源就像我有 header.phpfooter.php .但是,当我创建该文件并将其包含在我的 <head> 中时它不适用于相关页面。

我试过将它包含在 <head> 中标签和 <body> PHP 上方的标签包括 header.php但仍然没有结果。我也尝试了不同的格式。

<?php include 'includes/scripts.php'; ?>
<?php include ('includes/scripts.php'); ?>

我想包含如下文件:

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="styles.css">

header location for the code

index code location

scripts file

最佳答案

在你的header.php文件,和 script.php文件删除 <HTML> , <HEAD> , <BODY>标签,并删除 <meta charset="utf-8"> .在这两个文件中,只保留您想要包含到 index.php 中的内容。文件。

您不需要包含 script.php文件在 header.php文件,而是仅将其包含在 index.php 中文件。

所以你只能在你的 script.php 中保留这些东西文件:

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="styles.css">

也在你的header.php文件,您只能保留用 <nav> 包裹的内容元素,最后将这两个文件包含在您的 index.php 中文件如下:

<!DOCTYPE html>
<html>
<head>
<?php require('includes/script.php');?>
</head>
<body>
<?php require('includes/header.php');?>
// your rest of your elements here
</body>
</html>

关于包含来自 Head 标记的脚本和资源的 PHP 文件(包含 PHP 的问题),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57363029/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com