Home  >  Article  >  Backend Development  >  PHP自动生成后台导航网址的最佳方法_php技巧

PHP自动生成后台导航网址的最佳方法_php技巧

WBOY
WBOYOriginal
2016-05-17 08:55:41978browse

经常制作开发不同的网站的后台,写过很多种不同的后台导航写法。
最终积累了这种最写法,算是最好的吧。附上截图和代码如下(PHP+HTML)
PHP自动生成后台导航网址的最佳方法_php技巧 

复制代码 代码如下:


$linkArr = array(
'index.php' => '汇总首页',
'List.php' => '列表',
'Detail.php' => '详细',
'http://qzone.qq.com/' => 'QQ空间',
'http://qun.qzone.qq.com/group'=> '腾讯群首页',
'login.php?act=logout' => '安全退出',
);
?>



foreach($linkArr as $k => $v)
{
if(basename($k) == basename($_SERVER['PHP_SELF']))
{
$class = ' class="curr-ac"';
if(!defined('PAGE_TITLE')) define('PAGE_TITLE', $v);
} else {
$class = '';
}
echo '';
}
?>
<script> <BR>var PAGE_TITLE = <?php echo json_encode(defined('PAGE_TITLE') ? PAGE_TITLE : '');?>; <BR>if(PAGE_TITLE) document.title = PAGE_TITLE + ' ' + document.title; <BR>function Daohang(obj) <BR>{ <BR>var url = obj.getAttribute('_url'); <BR>if(/^https?:\/\/.+/i.test(url)) <BR>{ <BR>window.open(url,''); <BR>} else { <BR>window.location = url; <BR>} <BR>} <BR></script>

当然你也可以分开写。看自己如何应用。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn