PHP gets the code to search the keyword from Baidu to enter the website

Source: Internet
Author: User

  Below is a detailed code on how PHP can get the keyword from Baidu search into the site, and I hope this article will help the vast majority of PHP developers

Share a PHP access to search from Baidu to enter the site keyword code, the need for friends can refer to the:    code:  code as follows: <?php  function Search_word_from () {   $referer = isset ($_server[' http_referer '])? $_server[' http_referer ': ';  if (strstr ($referer, ' ') {//Baidu   Preg_match ("|baidu.+wo?r?d= ([^&]*) |is", $referer, $tmp);  $keyword = UrlDecode ($tmp [1]); &nbs P $from = ' Baidu '; (Ps:t good PHP Q-buckle 峮: 276167802, Validation: CSL)  }elseif (Strstr ($referer, ' ') or strstr ($referer, ' ')) {// Google   Preg_match ("|google.+q= ([^&]*) |is", $referer, $tmp);  $keyword = UrlDecode ($tmp [1]);  $from = ' Google '; }elseif strstr ($referer, ' ') {//360 search   Preg_match ("|so.+q= ([^&]*) |is", $referer, $tmp );  $keyword = UrlDecode ($tmp [1]);  $from = ' 360 '; }elseif (strstr ($referer, ' ')) {//Sogou   P Reg_match ("| ([^&]*) |is", $referer, $tmp);  $keyword = UrlDecode ($tmp [1]);  $from = ' SOG Ou '; }elseif (Strstr ( $referer, ' ')) {//Search   Preg_match ("| ([^&]*) |is", $referer, $tmp);  $keyword = Urldeco De ($tmp [1]);  $from = ' Soso '; }else {  $keyword = ';  $from = '; }    return array (' keyword ' => $keyword, ' from ' => $from); }   //below for test  //search keywords in search engines, go to website   $word = Search _word_from ();  if!empty ($word [' keyword ']) {  echo ' keyword: '. $word [' keyword ']. $word [' From ']; }  ?>    Above is this article on how to get the PHP search from Baidu to enter the site's keyword detailed code, I hope this article for the vast number of PHP developers to help, thank you for reading this article.    
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.