我需要開發一個頭文件,如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