Php 如何将元标记的内容从正文回显到标题
我正在尝试一些不确定如何进行的事情 我有一个header.php文件 我把它包含在页面中,所以现在我想添加meta标记,但不想使用相同的描述和关键字 如果我使用一个div标签,我将该页面搜索引擎中的描述中的内容放在正文中,然后在头文件中回显它,这样做有效吗?使用什么编码 谢谢,希望您能理解header.php中的:Php 如何将元标记的内容从正文回显到标题,php,Php,我正在尝试一些不确定如何进行的事情 我有一个header.php文件 我把它包含在页面中,所以现在我想添加meta标记,但不想使用相同的描述和关键字 如果我使用一个div标签,我将该页面搜索引擎中的描述中的内容放在正文中,然后在头文件中回显它,这样做有效吗?使用什么编码 谢谢,希望您能理解header.php中的: echo '<meta name="description" content = "'.$description.'">'; echo '<meta nam
echo '<meta name="description" content = "'.$description.'">';
echo '<meta name="keywords" content = "'.$keywords.'">';
在
header.php
文件中,定义一个创建头的函数:
function header($description, $keywords) {
...
echo "<meta name='description' content='$description' />";
echo "<meta name='keywords' content='$keywords' />";
...
}
稍后,当它在页面中创建DIV
时,它可以使用这些相同的变量
$pageTitle = 'Services';
$keyword = "Books a Party Hall and Room Rentals in Toronto";
$description = "Books a Party Hall and Room Rentals in Toronto. Halls rental for Events, Adult & Children's Birthday Parties, Photography, Wedding, Music and Fashion Show Shoots, Corporate Presentations, Baby Showers, Going Away and Engagement Parties.";
include 'header.php';
在标题中输入此代码
<title><?php echo $pageTitle; ?></title>
<meta name="keywords" content="<?php echo $keyword; ?>">
<meta name="description" content="<?php echo $description; ?>">
感谢您回答我如何将此变量转换为创建div,例如:echo“Description:$this_Description;”
$pageTitle = 'Services';
$keyword = "Books a Party Hall and Room Rentals in Toronto";
$description = "Books a Party Hall and Room Rentals in Toronto. Halls rental for Events, Adult & Children's Birthday Parties, Photography, Wedding, Music and Fashion Show Shoots, Corporate Presentations, Baby Showers, Going Away and Engagement Parties.";
include 'header.php';
<title><?php echo $pageTitle; ?></title>
<meta name="keywords" content="<?php echo $keyword; ?>">
<meta name="description" content="<?php echo $description; ?>">