我正在使用PHP包括在我的網頁上包含頁眉和頁腳。我在所有標題上都有一個導航欄,並且想知道是否有辦法讓header.phph在某些頁面上不顯示某些導航項目。例如,用戶不需要從聯繫頁面導航到聯繫頁面,因此該導航項目不是必需的。希望有人能夠協助。PHP包含,但只有某些東西
的index.php
<?php
include('header.php');
?>
<div class="third_bar">
<div class="second_image">
</div>
<div class="form">
<form action= "search.php" method="post">
<input type="text" id="search_bar" placeholder="" value="Search" max length="30" autocomplete="off" onMouseDown="active();" onBlur="inactive();"/><input type="submit" id="search_button" value="Go!"/>
</form>
</div>
</div>
<?php
include ('footer.php');
?>
的header.php
!doctype html>
<html>
<head>
<meta charset="utf8">
<link rel="icon" href="http://www.com/favicon.png?v=2"/>
<title>Wcom</title>
<link rel= "stylesheet" href="style5.css"/>
</head>
<script type="text/javascript">
function active() {
var search_bar= document.getElementById('search_bar');
if(search_bar.value == 'Search here') {
search_bar.value=''
search_bar.placeholder= 'Search here'
}
}
function inactive() {
var search_bar= document.getElementById('search_bar');
if(search_bar.value == '') {
search_bar.value='Search here'
search_bar.placeholder= ''
}
}
</script>
<div id="container">
<div class="top_section">
<div class="first_image">
<a href="#"><img src="logo.png"/></a>
</div>
</div>
<div class="nav_bar">
<a href ="#"> About us</a>
<a href ="#"> Products & Pricing</a>
<a href ="contactpage.php"> Contact us</a>
<a href ="#"> login</a>
</div>
<!doctype html>
<html>
<head>
<meta charset="utf8">
<link rel="icon" href="http://"/>
<title>?.com</title>
<link rel= "stylesheet" href="style5.css"/>
</head>
<script type="text/javascript">
function active() {
var search_bar= document.getElementById('search_bar');
if(search_bar.value == 'Search here') {
search_bar.value=''
search_bar.placeholder= 'Search here'
}
}
function inactive() {
var search_bar= document.getElementById('search_bar');
if(search_bar.value == '') {
search_bar.value='Search here'
search_bar.placeholder= ''
}
}
</script>
<div id="container">
<div class="top_section">
<div class="first_image">
<a href="#"><img src="logo.png"/></a>
</div>
</div>
<div class="nav_bar">
<a href ="#"> About us</a>
<a href ="#"> Products & Pricing</a>
<a href ="contactpage.php"> Contact us</a>
<a href ="#"> login</a>
</div>
榮譽的網站上的工作威士忌! –
那麼有人必須這樣做,它是一種艱苦的生活。 – Bill04
你應該在'header.php'代碼中實現一個邏輯,該代碼決定顯示哪些內容,哪些不顯示。實際上你可以通過使用客戶端邏輯來隱藏事物。 – arkascha