gpt4 book ai didi

php - 对特定页面使用包含和样式表?

转载 作者:行者123 更新时间:2023-11-28 14:51:42 25 4
gpt4 key购买 nike

我正要为我的网站使用包含,设置包含页眉、页脚、导航等。在页眉中,我将 DOCTYPE 添加到 </head> 的末尾标签。

如果我这样做,如果页面的头部在包含中,我将如何仅为一个特定页面添加样式表?

最佳答案

好吧,在包含的头文件 php 文件中有很多不同的方法可以做到这一点

添加一个变量

像这样

<?=@$css;?>

然后在包含它的文件中将 css 变量定义为您想要包含的任何内容

$css = 'something';

include(header.php);

如果这是你的 header.php

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<?=@$css;?>
</head>

这是你的 index.php

$css= '<link href="style.css" rel="stylesheet" type="text/css" />';
include('header.php');

关于php - 对特定页面使用包含和样式表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4503688/

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