How do I resolve a strpos() “empty delimiter” error?

核能气质少年 提交于 2019-12-05 00:34:28

This error occurs when the second parameter to strpos is empty. For instance, I can easily simulate this error at the command line:

$ php
<?php
echo strpos("foo", "");
?>
^D
Warning: strpos(): Empty delimiter in - on line 2

In your code, it means that $fgParams->get('base') is empty.

Add some checks to your code to ensure that the values you pass to strpos are valid, and the error will go away.

Change line 445

from

if($src = $img->getAttribute('src') AND strpos($src,$fgParams->get('base')) === false) { // prevents repeat processing

to

if($src = $img->getAttribute('src') AND $fgParams->get('base')!="" AND strpos($src,$fgParams->get('base')) === false) { // prevents repeat processing

Seems like that get('base') is returning nothing. Is this possible in your script? perhaps it's the indication of a previous error in another area of the program.

Please make sure that value of $fgParams->get('base') is not blank as json mentioned in condition.

Erwin

I had the same problem with:

if (htmlentities($controleren[$aantaltekens] == htmlentities($trans[$tellen])

The error disappeared when I added the two () delimiters:

if (htmlentities($controleren[$aantaltekens]) == htmlentities($trans[$tellen]))

So try:

if(($src = $img->getAttribute('src') AND strpos($src,$fgParams->get('base'))) === false)

Guess htmlentities requires its parameters to be within (delimiters).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!