// 正则匹配检查,并提取出参数
private function checkUrl($method, $str, $pattern) {
//echo "check $str with $pattern <br>";
$ma = array();
$pattern = ltrim(rtrim($pattern, "https://www.jb51.net/"));
$pattern = "https://www.jb51.net/".str_replace("https://www.jb51.net/", "\/", $pattern)."\/?$/";
$pattern = str_replace(":s", "([^\/]+)", $pattern);
//echo "pattern $pattern<br>";
//$str = "/\".$str."$/";
if (preg_match($pattern, $str, $ma) > 0) {
return $ma;
}
return null;
}
}
?>
php处理restful请求的路由类分享(2)
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:http://www.heiqu.com/305138cad8dd8c4d2e46560876a41f2c.html