开发者

PHP - What does Warning: strpos() [function.strpos]: Empty delimiter in mean?

开发者 https://www.devze.com 2023-01-23 21:01 出处:网络
What does Warning: strpos() [function.strpos]:开发者_如何转开发 Empty delimiter in mean? I have this:

What does Warning: strpos() [function.strpos]:开发者_如何转开发 Empty delimiter in mean?

I have this:

    if(strpos(''', $text) === false)
    {
        $text = str_replace(''', "'", $text);
    }


At a guess, I'd say $text is an empty string (thanks Mark for pointing out the specifics)

Edit: Also, another guess is you have the parameters in the wrong order. The method signature of strpos is

int strpos ( string $haystack , mixed $needle [, int $offset = 0 ] )

See http://php.net/manual/en/function.strpos.php


For starters you going about it all wrong....

  • strpos may return a false,"",0
  • the first argument must be the hastack
  • the second argument should be the needle.

what you should do is:

if(false !== ($position = strpos($text,'''))) //Position Found and set in $position
{
    //$position holds the offset to the needle.
    $text = str_replace(''', "'", $text);
}

petones


TRY ADDING double quotes on the on the variable $Text

Change: if(strpos(''', $text)

into: if(strpos(''', ".$text.")

if(strpos(''', ".$text.") === false)
    {
        $text = str_replace(''', "'", $text);
    }


I experienced this error after removing ?> from the end of the themes function.php in WP, but the error was only reported once.

0

精彩评论

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