PHP get detailed code _php tutorials for keywords from Baidu search into the site

Source: Internet
Author: User
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 () ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.