當前位置:首頁文章首頁 IT學院 PHP

關于php url路由的實現(xiàn)

作者:  來源:  發(fā)布時間:2011-5-20 15:09:52  點擊:
        }

        global $urlRule;

        if (isset($urlRule[$GLOBALS['control']][$GLOBALS['action']])){

                $aActionRule = &$urlRule[$GLOBALS['control']][$GLOBALS['action']];

                foreach ($aActionRule as $key=>$val){

                        // 規(guī)則值為 '' 時

                        if ($val == '') {

                                $queryString[$key] = '';

                                continue;

                        }

                        if (isset($aQueryString[0])){

                                // 取得正則表達式

                                $pattern = '/'.substr($val, strpos($val, ',')+1).'/';

                                // 模式匹配

                                if (preg_match($pattern, $aQueryString[0])){

                                        // 取值

                                        $queryString[$key] = $aQueryString[0];

                                        // 彈出值

                                        array_shift($aQueryString);

                                }else {

                                        // 取默認值

                                        $queryString[$key] = substr($val, 0, strpos($val, ','));

                                }

                        }else {

首頁 上一頁 [1] [2] [3]  下一頁 尾頁

文章評論

軟件按字母排列: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z