改进路由规则定义 APP_HOOK常量定义位置移动 便于应用模式自己定义

This commit is contained in:
thinkphp
2016-03-25 15:19:04 +08:00
parent ccfbd46bab
commit 3b6152c83c
3 changed files with 14 additions and 1 deletions

View File

@@ -598,6 +598,17 @@ class Route
$m2 = explode('/', $rule);
$var = [];
foreach ($m2 as $key => $val) {
// val中定义了多个变量 <id><name>
if (preg_match_all('/<(\w+)>/', $val, $matches)) {
foreach ($matches[1] as $name) {
$val = str_replace('<' . $name . '>', '(' . $pattern[$name] . ')', $val);
}
if (!preg_match('/^' . $val . '$/', $m1[$key])) {
return false;
}
continue;
}
if (0 === strpos($val, '[:')) {
// 可选参数
$val = substr($val, 1, -1);