php problem: strpos function not working

前端 未结 7 1473
鱼传尺愫
鱼传尺愫 2020-12-21 00:14

why is the following php code not working:

$string = \"123\";
$search = \"123\";

if(strpos($string,$search))
{
    echo \"found\";
}else{
    echo \"not fou         


        
7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-21 00:55

    This is happening because the search string is being found at position 0. Try

    if(strpos($string,$search) !== FALSE)

    instead of

    if(strpos($string,$search))

提交回复
热议问题