20,359
社区成员
发帖
与我相关
我的任务
分享
/*
* 验证输入的网址
* @param string $url:要匹配的网址
* @param string $base:模型网址,如taobao.com,jd.com
* @return bool
*/
public static function is_url($url,$base)
{
//将网址转换为小写
if(!empty($base)){
$base = strtolower($base);
}
//淘宝和天猫,共享域名
if($base=='taobao.com' || $base=='tmall.com'){
$base = "(taobao.com)|(tmall.com)";
}
$chars = "/((^http)|(^https)):\/\/(\S)+($base)(\S)+/"; //http(https)://***$base***
if (preg_match($chars, $url))
{
return true;
}
return false;
}