0

在我正在处理的网站中,我包含页眉和页脚。我希望能够在网站的每个页面上使用不同的元描述,但这让我感到困惑。标题效果很好,但我想知道这是否是因为涉及引号。

header.php 代码是:

<!DOCTYPE html>

<head>

<meta charset="UTF-8">  
<title><?php echo $title; ?></title>
<meta name="description" content="<?php echo $desc; ?>">
<meta name="keywords" content="neurologist, neurologic, neurology, nervous system, brain, seizure, epilepsy, carpal tunnel, seattle, ballard, washington, wa, king county, swedish hospital">

index.php 代码是:

<?php include ("header.php"); ?>
<?php $title = "Neurologic Clinic | Dr. Hal Rappaport | Seattle Neurologist"; ?>
<?php $desc = "Dr. Hal Rapport is a neurologist located in Seattle's Ballard neighborhood. He specializes in neurologic conditions and disorders and is also a certified psychologist"; ?>

感谢您提供任何帮助。

4

3 回答 3

2

这是因为您在包含标头之后分配变量,因此更改为

<?php $title = "Neurologic Clinic | Dr. Hal Rappaport | Seattle Neurologist"; ?>
<?php $desc = "Dr. Hal Rapport is a neurologist located in Seattle's Ballard neighborhood. He specializes in neurologic conditions and disorders and is also a certified psychologist"; ?>
<?php include ("header.php"); ?>
于 2013-04-28T22:04:36.083 回答
-1

首先,定义 $title, $desc。然后包含标题

<?php
    $title = "title";
    $desc = "description";

    include("header.php");
?>
于 2013-04-28T22:06:48.333 回答
-2

您不需要<?php ?>在每一行中都调用。

<?php
$title = "Neurologic Clinic | Dr. Hal Rappaport | Seattle Neurologist";
$desc = "Dr. Hal Rapport is a neurologist located in Seattle's Ballard neighborhood. He specializes in neurologic conditions and disorders and is also a certified psychologist";
include ("header.php");
?>
于 2013-04-28T22:07:55.240 回答