Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-警告:strpos()[function.strpos]:空分隔符的意思是什么?_Php - Fatal编程技术网

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

PHP-警告:strpos()[function.strpos]:空分隔符的意思是什么?,php,Php,警告:strpos()[function.strpos]:空分隔符的意思是什么 我有这个: if(strpos(''', $text) === false) { $text = str_replace(''', "'", $text); } 我猜,$text是一个空字符串(感谢Mark指出细节) 编辑:另外,另一个猜测是您的参数顺序错误。strpos的方法签名是 int strpos ( string $haystac

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

我有这个:

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

我猜,
$text
是一个空字符串(感谢Mark指出细节)

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

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

首先,请参见你的想法完全错了。

  • STRPO可能返回一个
    false
    0
  • 第一个参数必须是hastack
  • 第二个论点应该是针
你应该做的是:

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

petones

尝试在变量
$Text

更改:
if(strpos(“';”,$text)

进入:
if(strpos(“';”,“$text”)


从WP中的themes function.php的末尾删除?>后,我遇到了此错误,但该错误只报告了一次。

某些上下文可能会有所帮助。抱歉,鉴于最初缺乏详细信息,我只能具体地报告$text=“”.$text=NULL将返回false。找到它。前面的函数不检查文本是否为空:D感谢标记:D
strpos
如果无法找到指针,则返回布尔值
false
:“此函数可能返回布尔值
FALSE
,但也可能返回计算结果为
FALSE
的非布尔值,例如
0
。“…这就是我发表评论的原因!!!为了澄清,
strpos
将返回整数0,如果在干草堆的第一个位置找到指针。因此0==found,FALSE==notfound。正如问题所述,
==FALSE
,我猜他们只想在没有找到指针的情况下进入分支。”。
if(strpos(''', ".$text.") === false)
    {
        $text = str_replace(''', "'", $text);
    }