我需要开发一个头文件,如this如何在PHP中创建顶部标题和左侧标题?
其中顶部标题和左侧标题在整个网页中都是相同的。
我也创建了相同的,但我坚持在这里如何显示动态内容字段中的数据。 这里是我的代码header.php文件:
<!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>
<style>
main2{
font-family:myFirstFont1;
font-size:12px;
}
.image {
position: absolute;
left: 17px;
top: 159px;
}
.image1 { }
.image2 { }
.image3 { }
.main_divs{
display:inline-block;
float:left;
}
#left{
width:200px;
height:750px;
position:fixed;
margin-top:150px;
}
#upper{
width:100%;
float:left;
position:fixed;
display:inline-block
}
#logo{
width:352px;
margin-top:50px;
}
#navigation{ }
#logo,#navigation{
float:left
}
#inner-nav{
float:right;
margin-left: 200px;
}
.left_parts{
height:50%;
border-radius:10px;
border:2px solid black;
margin-top:10px;
}
#left-part1{
background-color:#0093dd;
}
#left-part2{
background-color:#bfff00;
}
main{
font-family:myFirstFont1;
margin-left:30px;
font-size:22px;
}
main1{
font-family:myFirstFont2;
}
</style>
</head>
<body>
<div id="upper" class="main_divs">
<div id="logo"><img src="images/Shoppin online .png" width="325px" height="50"/></div>
<div id="navigation">
<div id="inner-nav">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="35">
<main2><h3> <a href="index.html">HOME </a> | ABOUT US | CONTACT | <img src="images/twitter.png" width="21" height="17" /> | <img src="images/youtube.png" width="20" height="11" />; | <img src="images/fb.png" width="10" height="21" /> | <img src="images/in.png" width="20" height="14" /> | <img src="images/p.png" width="16" height="21" /> | <img src="images/setting.png" width="19" height="21" /> | <a href="signup.html">SIGNUP</a> | <a href="login.php">LOGIN</a></h3>
</main2>
</td>
</tr>
<tr>
<td height="40"><div class="image2"><input type="text" value="Search" maxlength="80" style="width:580px;height:25px;background-color:#bfff00" class="search">
<div class="text">
<main1><h2 class="t3"></h2></main1>
</div>
</div>
</td>
</tr>
<tr>
<td height="35"><div class="image2"><input type="text" value="Category" name="category" id="category" maxlength="80" style="width:100px;height:25px;background-color:#bfff00" class="search1"> <input type="text" value="Product Name" maxlength="80" style="width:120px;height:25px;background-color:#bfff00" class="search1"> <input type="text" value="Brand" maxlength="80" style="width:100px;height:25px;background-color:#bfff00" class="search1"> <input type="text" value="Price Range" maxlength="80" style="width:120px;height:25px;background-color:#bfff00" class="search1"> <input type="text" value="Color" maxlength="80" style="width:85px;height:25px;background-color:#bfff00" class="search1"></div></td>
</tr>
</table>
</div>
</div>
</div>
<div id="left" class="main_divs">
<div id="left-part1" class="left_parts">Offers</div>
<div id="left-part2" class="left_parts">New Arrivals</div>
</div>
</body>
</html>
,当我包括任何页面header.php文件,并插入内容,它们显示在网页的顶部,显示的header.php。
这里是我的test.php文件,其中包括header.php。
<?php
include_once("header/header.php")
?>
<!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>Testing</title>
</head>
<body>
tetsdfhgdfkgdfhgdfg
</body>
</html>
并且结果显示像this。
您的头文件中已经有了一个文档类型声明,因此在输出另一个文件之后当然只是无稽之谈。这同样适用于您已经拥有的完整HTML正文内容。 – CBroe 2015-02-10 10:39:25
您需要阅读一些关于模板基础知识。 – Seti 2015-02-10 10:41:45
所以我需要删除这句话:<!DOCTYPE html PUBLIC“ - // W3C // DTD XHTML 1.0 Transitional // EN”“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional。 dtd“> – 2015-02-10 10:43:18