thinkphp how to determine the phone-side access or PC-side access?

Source: Internet
Author: User

1 functionIsMobile ()2 {3         //If you have http_x_wap_profile, it must be a mobile device .4     if(isset($_server[' Http_x_wap_profile ']))5     return true;6 7     //if the VIA message contains a WAP, it must be a mobile device, and some service providers block that information8     if(isset($_server[' Http_via ']))9     {Ten     //not found for flase, otherwise true One     return Stristr($_server[' Http_via '], "WAP")?true:false; A     } -     //brain Residue method, determine the mobile phone to send the client logo, compatibility needs to be improved -     if(isset($_server[' Http_user_agent '])) the     { -         $clientkeywords=Array(' Nokia ', ' Sony ', ' Ericsson ', ' mot ', ' Samsung ', ' HTC ', ' SGH ', ' lg ', ' sharp ', ' sie-', ' Philips ', ' Panasonic ', ' Alcatel ', ' Lenovo ', ' iphone ', ' ipod ', ' blackberry ', ' Meizu ', ' Android ', ' NetFront ', ' Symbian ', ' UCWeb ', ' windowsce ', ' palm ', ' Operamini ', ' operamobi ', ' Openwave ', ' nexusone ', ' cldc ', ' MIDP ', ' wap ', ' mobile '); -         //find keywords for your phone's browser from Http_user_agent -         if(Preg_match("/(" .implode(' | ',$clientkeywords) . ")/I",Strtolower($_server[' Http_user_agent ']))) +             return true; -     } +         //protocol law, because there may be inaccuracies, put to the final Judgment A     if(isset($_server[' Http_accept '])) at     { -     //If only WML is supported and HTML is not supported it must be a mobile device . - //If WML and HTML are supported but WML is a mobile device before HTML -         if((Strpos($_server[' Http_accept '], ' vnd.wap.wml ')!==false) && (Strpos($_server[' Http_accept '], ' text/html ') = = =false|| (Strpos($_server[' Http_accept '], ' vnd.wap.wml ') <Strpos($_server[' Http_accept '], ' text/html ')))) -         { -             return true; in         } -     } to             return false;//then return false; +}

thinkphp how to determine the phone-side access or PC-side access?

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.