Think/Route.php
private static function checkUrlMatch($regx, $rule)
    {
        $m1 = explode('/', $regx);
        $m2 = explode('/', $rule);
        $var = [];
        foreach ($m2 as $key => $val) {
            if (0 === strpos($val, '[:')) {
                $val = substr($val, 1, -1);
            }

            if (':' == substr($val, 0, 1)) {
                // 动态变量
                if ($pos = strpos($val, '|')) {
                    // 使用函数过滤
                    $val = substr($val, 1, $pos - 1);
                }
                if (strpos($val, '\\')) {
                    $type = substr($val, -1);
                    if ('d' == $type) {
                        if (isset($m1[$key]) && !is_numeric($m1[$key])) {
                            return false;
                        }
                    }
                    $name = substr($val, 1, -2);
                } elseif ($pos = strpos($val, '^')) {
                    $array = explode('-', substr(strstr($val, '^'), 1));
                    if (in_array($m1[$key], $array)) {
                        return false;
                    }
                    $name = substr($val, 1, $pos - 1);
                } else {
                    $name = substr($val, 1);
                }
                $var[$name] = isset($m1[$key]) ? $m1[$key] : '';
            } elseif (0 !== strcasecmp($val, $m1[$key])) {
                return false;
            }
        }

        // 成功匹配后返回URL中的动态变量数组
        return $var;
    }
private static function checkUrlMatch($regx, $rule)
    {
        $m1 = explode('/', $regx);
        $m2 = explode('/', $rule);
        $var = [];
        foreach ($m2 as $key => $val) {
            if (0 === strpos($val, '[:')) {
                $val = substr($val, 1, -1);
            }

            if (':' == substr($val, 0, 1)) {
                // 动态变量
                if ($pos = strpos($val, '|')) {
                    // 使用函数过滤
                    $val = substr($val, 1, $pos - 1);
                }
                if (strpos($val, '\\')) {
                    $type = substr($val, -1);
                    if ('d' == $type) {
                        if (isset($m1[$key]) && !is_numeric($m1[$key])) {
                            return false;
                        }
                    }
                    $name = substr($val, 1, -2);
                } elseif ($pos = strpos($val, '^')) {
                    $array = explode('-', substr(strstr($val, '^'), 1));
                    if (in_array($m1[$key], $array)) {
                        return false;
                    }
                    $name = substr($val, 1, $pos - 1);
                } else {
                    $name = substr($val, 1);
                }
                $var[$name] = isset($m1[$key]) ? $m1[$key] : '';
            } elseif (0 !== strcasecmp($val, $m1[$key])) {
                return false;
            }
        }

        // 成功匹配后返回URL中的动态变量数组
        return $var;
    }
检测URL和规则路由是否匹配

@param $regx
@param $rule

@return array|bool