Share a PHP to get from Baidu search into the site of the keyword code, the need for Friends can refer to:
Code:
Copy CodeThe code is as follows:
function 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 '; (Ps:t good PHP q buckle 峮: 276167802, verify: CSL)
}elseif (Strstr ($referer, ' google.com ') or strstr ($referer, ' CN + + ')) {//Google
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 for keywords in search engines, go to website
$word = Search_word_from ();
if (!empty ($word [' keyword '])) {
echo ' keywords: '. $word [' keyword ']. ' From: '. $word [' from '];
}
?>
The above is the article about how to get the PHP from Baidu search into the site's keywords detailed code, I hope this article to the vast number of PHP developers to help, thanks to read this article.
http://www.bkjia.com/PHPjc/676887.html www.bkjia.com true http://www.bkjia.com/PHPjc/676887.html techarticle share a PHP to get from Baidu search into the site of the keyword code, there is a need for friends can refer to: Code: Copy code code as follows: Php function Search_word_from () ...