Question about strpos in PHP

后端 未结 2 464
臣服心动
臣服心动 2020-12-21 12:41

I\'m just trying to figure that out...

$mystring = \"/abc/def/hij\";
$find = \"/abc\";

echo(strpos($mystring, $find) . \"
\"); if (strpos($mystrin
2条回答
  •  醉话见心
    2020-12-21 13:19

    Test using the !== operator. This will compare types and values, as opposed to just values:

    $mystring = "/abc/def/hij";
    $find = "/abc";
    
    echo(strpos($mystring, $find) . "
    "); if (strpos($mystring, $find) !== false) { echo("found"); } else { echo("not found"); }

提交回复
热议问题