| This article introduces the following, a section can get search engine inbound keyword code, there is a need for friends reference. The code is as follows:
0) {$start =stripos ($url, ' & '); $s _s_keyword=substr ($url, 0, $start); } else {$s _s_keyword=substr ($url, 0); } return $s _s_keyword;} $url =isset ($_server[' http_referer '))? $_server[' Http_referer ']: ';//get the inbound URL. $search _1= "google.com"; q= $search _2= "baidu.com"; wd= $google =preg_match ("/\b{$search _1}\b/", $url);//record matching for inbound judgment. $baidu =preg_match ("/\b{$search _2}\b/", $url); $s _s_keyword= ""; if ($google) {//From Google $s _s_keyword=get_keyword ($url, ' q= ');//The character before the keyword is "q=". $s _s_keyword=urldecode ($s _s_keyword); $s _s_keyword=iconv ("GBK", "UTF-8", $s _s_keyword);//engine is GBK} else if ($baidu) {//from Baidu $s _s_keyword=get_keyword ($url, ' Wd= ');//The character before the keyword is "wd=". $s _s_keyword=urldecode ($s _s_keyword); $s _s_keyword=iconv ("GBK", "UTF-8", $s _s_keyword);//engine for GBK} echo ' $s _s_keyword ';? >Code Description: 1, note the issue of character encoding, because different search engines may return different encoding formats. 2, function more complete function, can refer to this article: Get search engine keyword source. |