ホームページ  >  記事  >  php教程  >  php路由URI

php路由URI

PHP中文网
PHP中文网オリジナル
2016-05-25 17:11:361595ブラウズ

   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;
    }
?>

                   

                   

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。