PHP - 警告:strpos() [function.strpos]: Empty delimiter in 是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4105067/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP - What does Warning: strpos() [function.strpos]: Empty delimiter in mean?
提问by Woppi
What does Warning: strpos() [function.strpos]: Empty delimiter in mean?
警告:strpos() [function.strpos]: Empty delimiter in 是什么意思?
I have this:
我有这个:
if(strpos(''', $text) === false)
{
$text = str_replace(''', "'", $text);
}
采纳答案by Phil
At a guess, I'd say $text
is an empty string (thanks Mark for pointing out the specifics)
猜测一下,我会说$text
是一个空字符串(感谢 Mark 指出细节)
Edit: Also, another guess is you have the parameters in the wrong order. The method signature of strpos is
编辑:另外,另一个猜测是您的参数顺序错误。strpos 的方法签名是
int strpos ( string $haystack , mixed $needle [, int $offset = 0 ] )
回答by RobertPitt
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.
- strpos 可能返回一个
false
,""
,0
- 第一个参数必须是hastack
- 第二个参数应该是针。
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
皮托内斯
回答by Dust Application
TRY ADDING double quotes on the on the variable $Text
尝试在变量上添加双引号 $Text
Change: if(strpos(''', $text)
改变: if(strpos(''', $text)
into: if(strpos(''', ".$text.")
进入: if(strpos(''', ".$text.")
if(strpos(''', ".$text.") === false)
{
$text = str_replace(''', "'", $text);
}
回答by Russell White
I experienced this error after removing ?> from the end of the themes function.php in WP, but the error was only reported once.
从WP中的themes function.php末尾删除?>后遇到此错误,但该错误仅报告一次。