From 8e6bd84741a9b4542a4b8e69aac61204e8df7787 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 13 Jan 2016 22:40:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=AF=E7=94=B1=E5=9C=B0=E5=9D=80=E4=B8=AD?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=AE=9A=E4=B9=89=E6=A8=A1=E5=9D=97/?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=99=A8/=E6=93=8D=E4=BD=9C=E5=8F=98?= =?UTF-8?q?=E9=87=8F=20=E4=BE=8B=E5=A6=82=EF=BC=9A=20'user/:action'=3D>'in?= =?UTF-8?q?dex/user/:action'=20':controller/:action'=3D>'index/:controller?= =?UTF-8?q?/:action'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/library/think/Route.php b/library/think/Route.php index 8591d82a..eae53575 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -575,15 +575,17 @@ class Route } else { // 解析路由地址 $result = self::parseRoute($url); - $var = $result['var']; - // 解析路由地址里面的动态参数 - $values = array_values($matches); - foreach ($var as $key => $val) { - if (0 === strpos($val, ':')) { - $var[$key] = $values[substr($val, 1) - 1]; + // 解析路由地址中的变量 + foreach ($result['route'] as $key => $item) { + if (0 === strpos($item, ':')) { + $item = substr($item, 1); + if (isset($matches[$item])) { + $result['route'][$key] = $matches[$item]; + unset($matches[$item]); + } } } - $var = array_merge($matches, $var); + $var = array_merge($matches, $result['var']); // 解析剩余的URL参数 self::parseUrlParams(implode('/', $paths), $var); $result = ['type' => 'module', 'module' => $result['route']];