开发者

Error in preg_match PHP

<?php

$str = "asd,ad";
if(preg_match(",",$str)) { 
    echo "ok";
}

?

It outputs me

开发者_运维问答

No ending delimiter ',' found in....

?>


your pattern can be replaced to strpos instead

if(strpos($str, ",")!==false)
{
   echo "ok";
}


You are missing delimitters, try this:

$str = "asd,ad";
if(preg_match("/,/",$str)) { 
    echo "ok";
}

To find out more instances, you may want to use preg_match_all function too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜