当前位置:首页文章首页 IT学院 PHP

关于php url路由的实现

作者:  来源:  发布时间: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){

                        // 规则值为 '' 时

                        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