Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning: strpos(): Empty needle in ......wordpress Plugin [closed]

I get this error :

Warning: strpos(): Empty needle in ......popularity-contest.php on line 2574

function akpc_is_searcher() {
        global $akpc;
        $referrer = parse_url($_SERVER['HTTP_REFERER']);
        $searchers = explode(' ', preg_replace("\n|\r|\r\n|\n\r", ' ', $akpc->searcher_names));
        foreach ($searchers as $searcher) {
                if (strpos($referrer['host'], $searcher) !== false) {
                        return true;
                }
        }
        return false;
}

Can someone please help me to fix this problem?

like image 570
user57139 Avatar asked Oct 12 '14 13:10

user57139


1 Answers

A bunch of PHP search functions use the terms "needle" and "haystack" as their parameter names, indicating what is sought and where to seek it.

The strpos function is such a function. "Empty needle" means that you have passed in a null or empty value as the needle to look for. This is like saying "search for nothing" which doesn't make sense to the function.

To fix this, check that the variable that you're passing in as the needle has an actual value. The empty function is a good choice for that.

like image 64
Dancrumb Avatar answered Sep 24 '22 07:09

Dancrumb