php»ñÈ¡ ´Ó°Ù¶ÈËÑË÷½øÈëÍøÕ¾µÄ¹Ø¼ü´Ê_PHP Tutorial

WBOY
Release: 2016-07-20 11:12:33
Original
4019 people have browsed it

php»ñÈ¡´Ó°Ù¶ÈËÑË÷½øÈëÍøÕ¾µÄ¹Ø¼ü´Ê

<?php
 
function search_word_from() {
    $referer = isset($_SERVER[&#39;HTTP_REFERER&#39;])?$_SERVER[&#39;HTTP_REFERER&#39;]:&#39;&#39;;
    if(strstr( $referer, &#39;baidu.com&#39;)){ //°Ù¶È
        preg_match( "|baidu.+wo?r?d=([^\\&]*)|is", $referer, $tmp );
        $keyword = urldecode( $tmp[1] );
        $from = &#39;baidu&#39;;
    }elseif(strstr( $referer, &#39;google.com&#39;) or strstr( $referer, &#39;google.cn&#39;)){ //¹È¸è
        preg_match( "|google.+q=([^\\&]*)|is", $referer, $tmp );
        $keyword = urldecode( $tmp[1] );
        $from = &#39;google&#39;;
    }elseif(strstr( $referer, &#39;so.com&#39;)){ //360ËÑË÷
        preg_match( "|so.+q=([^\\&]*)|is", $referer, $tmp );
        $keyword = urldecode( $tmp[1] );
        $from = &#39;360&#39;; 
    }elseif(strstr( $referer, &#39;sogou.com&#39;)){ //Ëѹ·
        preg_match( "|sogou.com.+query=([^\\&]*)|is", $referer, $tmp );
        $keyword = urldecode( $tmp[1] );
        $from = &#39;sogou&#39;;   
    }elseif(strstr( $referer, &#39;soso.com&#39;)){ //ËÑËÑ
        preg_match( "|soso.com.+w=([^\\&]*)|is", $referer, $tmp );
        $keyword = urldecode( $tmp[1] );
        $from = &#39;soso&#39;;
    }else {
        $keyword =&#39;&#39;;
        $from = &#39;&#39;;
    }
 
    return array(&#39;keyword&#39;=>$keyword,&#39;from&#39;=>$from);
}
 
//ÒÔÏÂΪ²âÊÔ
//ÔÚËÑË÷ÒýÇæËÑË÷¸ö¹Ø¼ü´Ê£¬½øÈëÍøÕ¾
$word = search_word_from();
if(!empty($word[&#39;keyword&#39;])){
    echo &#39;¹Ø¼ü×Ö£º&#39;.$word[&#39;keyword&#39;].&#39; À´×Ô£º&#39;.$word[&#39;from&#39;];
}
?>
Copy after login

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/444549.htmlTechArticlephp»ñÈ¡´Ó°Ù¶ÈËÑË÷½øÈëÍøÕ¾µÄ¹Ø¼ü´Ê ?php function search_word_from() { $referer = isset($_SERVER[HTTP_REFERER])?$_SERVER[HTTP_REFERER]:; if(strstr( $refe...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template