PHP - 什么警告:strpos()[function.strpos]:空分隔符是什么意思?

Wop*_*ppi 6 php

警告:strpos()[function.strpos]:空分隔符是什么意思?

我有这个:

    if(strpos(''', $text) === false)
    {
        $text = str_replace(''', "'", $text);
    }
Run Code Online (Sandbox Code Playgroud)

Phi*_*hil 4

据猜测,我会说$text是一个空字符串(感谢马克指出细节)

编辑:另外,另一种猜测是您的参数顺序错误。strpos 的方法签名是

int strpos ( string $haystack , mixed $needle [, int $offset = 0 ] )
Run Code Online (Sandbox Code Playgroud)

请参阅http://php.net/manual/en/function.strpos.php

  • 特别是$text =“”。$text = NULL 将简单地返回 false。 (2认同)