如何确保它只有一个http://在一个字符串中?如何确保在一个字符串中只有一个http://?
$url = "http://mysite.com/http://http://mysite.com/";
# set the regex for checking.
$regex = '/^\bhttp:\b\/\/.*/';
# reject the url address if it doesn't match
if (!preg_match($regex, $url)) echo 'false';
它是有效的URL,你为什么要过滤它? – nhahtdh 2013-03-04 18:14:47
@nhahtdh显然,有效性以外的原因。 – showdev 2013-03-04 18:21:22
我希望他不使用这个来过滤“坏”的URL。 – nhahtdh 2013-03-04 18:35:47