PHP Preg_match()未知的修饰符URL

时间:2013-08-05 06:22:48

标签: php preg-match

我收到此错误消息:

Warning: preg_match(): Unknown modifier '/' in C:\xampp\htdocs\easyblog\wp-content\themes\easyblog\inc\widget\flickr.php on line 225

此处的源代码:

// Screen name or RSS in $username?
if (!preg_match("/http://api.flickr.com/services/feeds/", $username))
$url = "http://api.flickr.com/services/feeds/photos_public.gne?id=".urlencode($user_id)."&format=".$flickrformat."&lang=en-us".$tags;
else
$url = $username."&format=".$flickrformat.$tags;

请有人帮助我!

2 个答案:

答案 0 :(得分:1)

你需要在表达式中转义正斜杠:

"/http:\/\/api.flickr.com\/services\/feeds/"

答案 1 :(得分:1)

使用/分隔符时,如果在模式中使用,则必须转义所有/字符,为避免这种情况,您可以使用其他分隔符,例如#

"#http://api.flickr.com/services/feeds#"

但是,您的模式需要转义:

"/http:\/\/api.flickr.com\/services\/feeds/"