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.com ') {//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, ' google.com ') or strstr ($referer, ' google.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 P Reg_match ("|sogou.com.+query= ([^&]*) |is", $referer, $tmp); $keyword = UrlDecode ($tmp [1]); $from = ' SOG Ou '; }elseif (Strstr ( $referer, ' soso.com ')) {//Search Preg_match ("|soso.com.+w= ([^&]*) |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.