<?PHP/** * Present company in use, not perfect place to look forward to*/classFromphoneorpc {//Judging from a computer or cell phone Public functionJudgefrom () {$uAgent=$_server[' Http_user_agent ']; $hAccept=$_server[' Http_accept ']; $osPat= "mozilla|m3gate|winwap|openwave| Windows nt| Windows 3.1|95| blackcomb|98| me| X window|ubuntu| longhorn| Aix| amigaos| beos| Hp-ux| openbsd| freebsd| netbsd| os\/2| osf1| SUN "; $phonePat= "iphone| Linux| android| symbian| Windows Phone OS "; if(Preg_match("/($phonePat)/I ",$uAgent)) { return' Phone '; } Else if(Preg_match("/($osPat)/I ",$uAgent)) { if(isset($_server[' Http_accept ']) && (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' Phone '; } Else { return"PC"; } } Else { return' Phone '; } }}//1, the current smart phone will display the system are eliminated////2, and then eliminate the WAP format header////3, the rest of the basic is the PC
Judging from a computer or cell phone