php»ñÈ¡´Ó°Ù¶ÈËÑË÷½øÈëÍøÕ¾µÄ¹Ø¼ü´Ê
程序员文章站
2022-06-01 20:13:11
...
php»ñÈ¡´Ó°Ù¶ÈËÑË÷½øÈëÍøÕ¾µÄ¹Ø¼ü´Ê
<?php function search_word_from() { $referer = isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:^^ `; if(strstr( $referer, 'baidu.com')){ //°Ù¶È preg_match( "|baidu.+wo?r?d=([^\\&]*)|is", $referer, $tmp ); $keyword = urldecode( $tmp[1] ); $from = 'baidu'; }elseif(strstr( $referer, 'google.com') or strstr( $referer, 'google.cn')){ //¹È¸è preg_match( "|google.+q=([^\\&]*)|is", $referer, $tmp ); $keyword = urldecode( $tmp[1] ); $from = 'google'; }elseif(strstr( $referer, 'so.com')){ //360ËÑË÷ preg_match( "|so.+q=([^\\&]*)|is", $referer, $tmp ); $keyword = urldecode( $tmp[1] ); $from = '360'; }elseif(strstr( $referer, 'sogou.com')){ //Ëѹ· preg_match( "|sogou.com.+query=([^\\&]*)|is", $referer, $tmp ); $keyword = urldecode( $tmp[1] ); $from = 'sogou'; }elseif(strstr( $referer, 'soso.com')){ //ËÑËÑ preg_match( "|soso.com.+w=([^\\&]*)|is", $referer, $tmp ); $keyword = urldecode( $tmp[1] ); $from = 'soso'; }else { $keyword =^^ `; $from = ^^ `; } return array('keyword'=>$keyword,'from'=>$from); } //ÒÔÏÂΪ²âÊÔ //ÔÚËÑË÷ÒýÇæËÑË÷¸ö¹Ø¼ü´Ê£¬½øÈëÍøÕ¾ $word = search_word_from(); if(!empty($word['keyword'])){ echo '¹Ø¼ü×Ö£º'.$word['keyword'].' À´×Ô£º'.$word['from']; } ?>
以上就是php»ñÈ¡´Ó°Ù¶ÈËÑË÷½øÈëÍøÕ¾µÄ¹Ø¼ü´Ê的内容,更多相关内容请关注PHP中文网(www.php.cn)!
上一篇: 问问大家都怎么结合Linux开发的