开发者

Error in preg_match PHP

开发者 https://www.devze.com 2023-02-01 19:24 出处:网络
<?php $str = \"asd,ad\"; if(preg_match(\",\",$str)) { echo \"ok\"; } ? It outputs me 开发者_运维问答 No ending delimiter \',\' found in....
<?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

精彩评论

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