Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在dreamweaver中设置其他页面的页面标题和元标记_Php_Html_Dreamweaver - Fatal编程技术网

Php 在dreamweaver中设置其他页面的页面标题和元标记

Php 在dreamweaver中设置其他页面的页面标题和元标记,php,html,dreamweaver,Php,Html,Dreamweaver,我正在使用Dreamweaver CS5开发一个php web应用程序。创建新页面时,Dreamweaver会自动添加以下代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> head>

我正在使用Dreamweaver CS5开发一个php web应用程序。创建新页面时,Dreamweaver会自动添加以下代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>

头>
无标题文件
我要做的是把这段代码放到一个文件中,比如'head.php',然后我想把这个head.php文件导入到我使用

<?php include("head.php"); ?>

如果我这样做,这意味着我将为每个页面提供相同的页面标题,因为代码
无标题文档
包含在head.php中

那么,有没有一种方法可以让我通过我创建的新页面中的变量发送页面标题,然后在head.php文档中设置它呢。因此,如果我有一个customer.php页面,它会像这样

$pageTitle = "Customer List";
<?php include("head.php"); ?>
$pageTitle=“客户列表”;
然后将$pageTitle传递给header.php中的header.php

function header($title)
{
 echo '<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>.$title.</title>
 </head>';
}
函数头($title)
{
回声'
$title。
';
}
然后包括head.php

<?php include(“head.php”);?>

最后,主文件中的标记调用函数来创建标题

<?php header('This is my Awesome Page'); ?>

还是

<?php 
  $pageTitle = "My Title";
  header($pageTitle); 
?>

这应该对你有用