熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> PHP編程 >> 正文

PHP通過訪客來路獲取搜索關鍵詞的方法

2013-11-15 12:35:17  來源: PHP編程 

  <?php class keyword{ public function getKeyword($referer){ if(strpos($referer"{ $keyword = $this>getbaidukeyword($referer); }else if(strpos($referer"{ $keyword = $this>getgooglekeyword($referer); }else if(strpos($referer"{ $keyword = $this>getsosokeyword($referer); }else if(strpos($referer"{ $keyword = $this>getsogoukeyword($referer); } return $keyword; } //由來路取得百度關鍵詞 private function getbaidukeyword($str){ $s = strpos($strwd=); if($s>){ $str = substr($str$s+); $e = strpos($str&); if($e>){ $str = substr($str$e); } $str = rawurldecode($str); } return $str; } //獲得谷歌關鍵詞 private function getgooglekeyword($str){ $s = strpos($str&q=); if($s>){ $str = substr($str$s+); $e = strpos($str&); if($e>){ $str = substr($str$e); } $str = rawurldecode($str); } return $str; } //獲得SOSO關鍵詞 private function getsosokeyword($str){ $s = strpos($str?w=); if($s>){ $str = substr($str$s+); $e = strpos($str&); if($e>){ $str = substr($str$e); } $str = rawurldecode($str); }else{ $s = strpos($str&w=); if($s>){ $str = substr($str$s+); $e = strpos($str&); if($e>){ $str = substr($str$e); } $str = rawurldecode($str); } } return $str; } //獲得sogou關鍵詞 private function getsogoukeyword($str){ $s = strpos($strquery=); if($s>){ $str = substr($str$s+); $e = strpos($str&); if($e>){ $str = substr($str$e); } $str = rawurldecode($str); } return $str; } } ?>


From:http://tw.wingwit.com/Article/program/PHP/201311/21223.html
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.