首页 > php教程 > PHP源码 > php路由URI

php路由URI

PHP中文网
发布: 2016-05-25 17:11:36
原创
1669 人浏览过

   1. [代码]php路由  

<?
    function seo_uri (){
        $uri_arr = explode("/",trim($_SERVER[&#39;REQUEST_URI&#39;],&#39;/&#39;));
        $web_root_str = strtr(WEB_ROOT,&#39;/&#39;,&#39;\\&#39;);
        $root_path_arr = explode(&#39;\\&#39;,trim($web_root_str,&#39;\\&#39;));
        $root_path_count = count($root_path_arr);
        foreach($uri_arr as $key=>$val){
            if($val==$root_path_arr[$root_path_count-1]){
                $uri_arr_start = $key;
            }
        }
        if($uri_arr_start>=&#39;0&#39;){
            $uri_new = array_slice($uri_arr,$uri_arr_start+1);
        }else{
            $uri_new = $uri_arr;
        }
        $uri[&#39;mod&#39;]=isset($_GET[&#39;mod&#39;])?$_GET[&#39;mod&#39;]:(isset($uri_new[&#39;0&#39;])?(!empty($uri_new[&#39;0&#39;])?$uri_new[&#39;0&#39;]:"index"):"index");
        $uri[&#39;act&#39;]=isset($_GET[&#39;act&#39;])?$_GET[&#39;act&#39;]:(isset($uri_new[&#39;1&#39;])?(!empty($uri_new[&#39;1&#39;])?$uri_new[&#39;1&#39;]:"index"):"index");
        if(count($uri_new)>2){
            $uri[&#39;uri&#39;] = array_slice($uri_new,1);
        }
        return $uri;
    }
?>
登录后复制

                   

                   

相关标签:
php
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
最新问题
怎么学好php
来自于 1970-01-01 08:00:00
0
0
0
PHP扩展intl
来自于 1970-01-01 08:00:00
0
0
0
php数据获取?
来自于 1970-01-01 08:00:00
0
0
0
热门推荐
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板