From 67fe68484584a3b81e3677cdc2dd454fc24ba01d Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 25 Mar 2013 21:06:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Think/Route.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Think/Route.php b/Think/Route.php index d0b519e9..7f0ae0b2 100644 --- a/Think/Route.php +++ b/Think/Route.php @@ -89,7 +89,6 @@ class Route { foreach ($rules as $rule=>$route){ if(0===strpos($rule,'/') && preg_match($rule,$regx,$matches)) { // 正则路由 if($route instanceof \Closure) { - array_shift($matches); // 执行闭包并中止 self::invokeRegx($route,$matches); exit; @@ -123,11 +122,12 @@ class Route { return self::parseUrl($regx); } - // 执行正则匹配下的闭包方法 + // 执行正则匹配下的闭包方法 支持参数调用 static private function invokeRegx($closure,$var=[]) { $reflect = new \ReflectionFunction($closure); $params = $reflect->getParameters(); $args = []; + array_shift($var); foreach ($params as $param){ $name = $param->getName(); if(!empty($var)) { @@ -139,7 +139,7 @@ class Route { $reflect->invokeArgs($args); } - // 执行规则匹配下的闭包方法 + // 执行规则匹配下的闭包方法 支持参数调用 static private function invokeRule($closure,$var=[]) { $reflect = new \ReflectionFunction($closure); $params = $reflect->getParameters();