如何确保字符串中只有一个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';
如何确保字符串中只有一个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';