From abeb4dca94c8b6398a942a464be956e2060d9f1f Mon Sep 17 00:00:00 2001 From: huangdijia Date: Fri, 4 Dec 2015 23:02:31 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=AF=E7=94=B1=E4=BC=98=E5=8C=96=20?= =?UTF-8?q?=E7=AE=80=E5=8C=96=E9=A2=9D=E5=A4=96=E5=8F=82=E6=95=B0=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/route.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/library/think/route.php b/library/think/route.php index de1712ba..2989a7da 100644 --- a/library/think/route.php +++ b/library/think/route.php @@ -446,19 +446,17 @@ class Route parse_str($url, $var); } if (isset($path)) { - $params = []; + // 解析path额外的参数 if (!empty($path[3])) { - $params = explode('/', array_pop($path)); + preg_replace_callback('/([^\/]+)\/([^\/]+)/', function ($match) use (&$var) { + $var[strtolower($match[1])] = strip_tags($match[2]); + }, array_pop($path)); } // 解析[模块/控制器/操作] $action = array_pop($path); $action = '[rest]' == $action ? REQUEST_METHOD : $action; $controller = !empty($path) ? array_pop($path) : null; $module = !empty($path) ? array_pop($path) : null; - // 解析path额外的参数 - for ($i = 0; $i < count($params); $i++) { - $var[$params[$i]] = $params[++$i]; - } } return ['route' => [$module, $controller, $action], 'var' => $var]; }