Skip to content
Advertisement

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|rn|nr", ' ', $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?

Advertisement

Answer

The warning should go away if you set WP_DEBUG to false in wp_config.php. If you want to fix it, try the following:

function akpc_is_searcher() {
        global $akpc;
        $referrer = parse_url($_SERVER['HTTP_REFERER']);
        $searchers = explode(' ', preg_replace("n|r|rn|nr", ' ', $akpc->searcher_names));
        foreach ($searchers as $searcher) {
                if ( ! empty($searcher) && strpos($referrer['host'], $searcher) !== false) {
                        return true;
                }
        }
        return false;
}
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement