只需把单独写nav.php文件
<?php $f=$_SERVER[‘PHP_SELF‘];?>
<div class="nav">
<div class="navcon">
<ul>
<li <?= $f==‘/index.php‘ ? ‘class="navhome"‘ :‘‘?>><a href="#">首页</a></li>
<li <?= $f==‘/news.php‘ ? ‘class="navhome"‘ :‘‘?>><a href="#">新闻中心</a></li>
<li <?= $f==‘/about.php‘ ? ‘class="navhome"‘ :‘‘?>><a href="#">关于我们</a></li>
<li <?= $f==‘/pro.php‘ ? ‘class="navhome"‘ :‘‘?>><a href="#">精品工程</a></li>
<li <?= $f==‘/zzry.php‘ ? ‘class="navhome"‘ :‘‘?>><a href="#">资质荣誉</a></li>
<li <?= $f==‘/woker.php‘ ? ‘class="navhome"‘ :‘‘?>><a href="#">员工风采</a></li>
<li <?= $f==‘/guestbook.php‘ ? ‘class="navhome"‘ :‘‘?>><a href="#">在线留言</a></li>
<li <?= $f==‘/job.php‘ ? ‘class="navhome"‘ :‘‘?>class="navlast"><a href="job.php">诚聘英才</a></li>
</ul>
</div>
</div>
然后在某个页面的导航部分引入
<?php include ‘nav.php‘;?>
时间: 2024-11-03 05:21:53