PHP access from Baidu, Google and other search engines to enter the Site keyword method, Google keywords
The example of this article describes the PHP access from Baidu, Google and other search engines to enter the Site keyword method. Share to everyone for your reference. The implementation method is as follows:
<?phpfunction Search_word_from () {$referer = Isset ($_server[' http_referer '])? $_server[' Http_referer ']: '; if ( Strstr ($referer, ' baidu.com ')) {//Baidu 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 search Preg_match ("|so.+q= ([^\\&]*) |is", $referer, $tmp); $keyword = UrlDecode ($tmp [1]); $from = ' 360 '; }elseif (Strstr ($referer, ' sogou.com ')) {//Sogou Preg_match ("|sogou.com.+query= ([^\\&]*) |is", $referer, $tmp); $keyword = UrlDecode ($tmp [1]); $from = ' Sogou '; }elseif (Strstr ($referer, ' soso.com ')) {//Search Preg_match ("|soso.com.+w= ([^\\&]*) |is", $referer, $tmp); $keyword = UrlDecode ($tmp [1]); $from = ' Soso '; }else {$keyword = '; $from = "; } return Array ('Keyword ' = $keyword, ' from ' + $from);} The following is a test//search keyword in the search engine, enter the site $word = Search_word_from (); if (!empty ($word [' keyword ')) {echo ' keyword: '. $word [' keyword ']. ' From: '. $word [' from '];}? >
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/1028967.html www.bkjia.com true http://www.bkjia.com/PHPjc/1028967.html techarticle PHP to get from Baidu, Google and other search engines to enter the Site keyword method, Google keywords This example tells the PHP get from Baidu, Google and other search engines to enter the Site keyword method ...