PHP method for retrieving search keywords by visitor

Source: Internet
Author: User
PHP's method of retrieving search keywords by visitor & lt ;? Phpclasskeyword {publicfunctiongetKeyword ($ referer) {if (strpos ($ referer, & quot; www.baidu.com & quot;) & gt;-1) {$ keyword $ this-& gt; getba PHP method for retrieving search keywords by visiting a visitor
 -1) {$ keyword = $ this-> getbaidukeyword ($ referer);} else if (strpos ($ referer ," http://www.google.com ")>-1) {$ keyword = $ this-> getgooglekeyword ($ referer);} else if (strpos ($ referer ," http://www.soso.com ")>-1) {$ keyword = $ this-> getsosokeyword ($ referer);} else if (strpos ($ referer ," http://www.sogou.com ")>-1) {$ keyword = $ this-> getsogoukeyword ($ referer);} return $ keyword;} // Obtain Baidu keyword private function getbaidukeyword ($ str) {$ s = strpos ($ str, 'wd = '); if ($ s>-1) {$ str = substr ($ str, $ s + 3 ); $ e = strpos ($ str, '&'); if ($ e>-1) {$ str = substr ($ str, 0, $ e );} $ str = rawurldecode ($ str);} return $ str;} // Obtain the Google keyword private function getgooglekeyword ($ str) {$ s = strpos ($ str, '& q ='); if ($ s>-1) {$ str = substr ($ str, $ s + 3); $ e = strpos ($ s Tr, '&'); if ($ e>-1) {$ str = substr ($ str, 0, $ e );} $ str = rawurldecode ($ str);} return $ str;} // Obtain the SOSO keyword private function getsosokeyword ($ str) {$ s = strpos ($ str ,'? W = '); if ($ s>-1) {$ str = substr ($ str, $ s + 3); $ e = strpos ($ str, '&'); if ($ e>-1) {$ str = substr ($ str, 0, $ e) ;}$ str = rawurldecode ($ str );} else {$ s = strpos ($ str, '& w ='); if ($ s>-1) {$ str = substr ($ str, $ s + 3 ); $ e = strpos ($ str, '&'); if ($ e>-1) {$ str = substr ($ str, 0, $ e );} $ str = rawurldecode ($ str) ;}return $ str ;}// obtain the sogou keyword private function getsogoukeyword ($ str) {$ s = strpos ($ str, 'query = '); if ($ s>-1) {$ str = substr ($ str, $ s + 6 ); $ E = strpos ($ str, '&'); if ($ e>-1) {$ str = substr ($ str, 0, $ e );} $ str = rawurldecode ($ str);} return $ str ;}}?>

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.