Hilighting当前导航选项卡使用PHP中的URL [英] Hilighting The Current Navigation Tab Using URL in PHP
本文介绍了Hilighting当前导航选项卡使用PHP中的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用php url,使用和不使用.php扩展程序缩小当前导航标签
Hilighing the current navigation tab using php url ,with and with out .php Extension
//php code
function curPageName() {
return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
}
$Current=curPageName();;
?>
// HTML,CSS
//HTML,CSS
<li id=<?php if ("index.php"==$Current) echo "selected";else echo "";?>>
推荐答案
希望它有帮助
<?php
function curPageName() {
return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
}
$Current=curPageName();
$nav_tabs=array('home','about','products','contacts');
foreach($nav_tabs as $nav)
{
if($nav == $current)
{
echo"<li class='active' > <a href='$nav' > $nav </a></li>";
}
else
{
echo"<li > <a href='$nav' > $nav </a></li>";
}
}
?>
// in CSS define active to highlight the tab
// in CSS define active to highlight the tab
.active{
background-color:black;
font-white;
}
这篇关于Hilighting当前导航选项卡使用PHP中的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文