Home > php教程 > PHP源码 > php路由URI

php路由URI

PHP中文网
Release: 2016-05-25 17:11:36
Original
1637 people have browsed it

   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;
    }
?>
Copy after login

                   

                   

Related labels:
php
source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template