dongren1011 2014-10-12 13:03
浏览 379
已采纳

警告:strpos():空针... wordpress插件[关闭]

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

  • 写回答

2条回答 默认 最新

  • dongmeng0317 2014-10-12 13:11
    关注

    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("
    ||
    |
    ", ' ', $akpc->searcher_names));
            foreach ($searchers as $searcher) {
                    if ( ! empty($searcher) && strpos($referrer['host'], $searcher) !== false) {
                            return true;
                    }
            }
            return false;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?