复制代码 代码如下:

Home >Backend Development >PHP Tutorial >The best way to automatically generate background navigation URLs in PHP_PHP Tutorial

The best way to automatically generate background navigation URLs in PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 14:59:15999browse

I often create and develop the backends of different websites, and have written many different ways of writing backend navigation.
I finally accumulated this best writing method, which is probably the best. Attached are screenshots and code as follows (PHP+HTML)
The best way to automatically generate background navigation URLs in PHP_PHP Tutorial

Copy code The code is as follows:

< ;?php

$linkArr = array(
'index.php' => 'Summary homepage',
'List.php' => 'List',
'Detail .php' => 'Details',
'http://qzone.qq.com/' => 'QQ Zone',
'http://qun.qzone.qq.com/group '=> 'Tencent group homepage',
'login.php?act=logout' => 'Safe exit',
);
?>



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>

Of course you can also write them separately . See how you apply it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328153.htmlTechArticleI often develop the backends of different websites and have written many different backend navigation methods. In the end, I accumulated this best writing method, which is probably the best. Attached are the screenshots and code as follows (PHP+HT...
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