The JavaScript judgment method is to directly search the Android string in the user agent string of the client:
If (navigator. userAgent. match (/Android/I )){
Alert ('Is Android! ');
} Else {
Alert ('is Not Android! ');
}
The PHP method can also be used to search for Android keywords in the user agent:
If (strstr ($ _ SERVER ['http _ USER_AGENT '], 'Android ')){
Echo 'Is Android! ';
} Else {
Echo 'Is Not Android! ';
}
Next, let's talk about
Php Tutorial: determine the browser type based on HTTP_USER_AGENT
Function browsers (){
Global $ HTTP_USER_AGENT;
If (isset ($ HTTP_USER_AGENT )){
$ SAgent = $ HTTP_USER_AGENT;
} Else {
$ SAgent = $ _ SERVER ['http _ USER_AGENT '];
}
If (strpos ($ sAgent, 'msi ')! ==False & strpos ($ sAgent, 'Mac') ===false & strpos ($ sAgent, 'Opera ') === false ){
$ IVersion = (float) substr ($ sAgent, strpos ($ sAgent, 'msie ') + 5, 3 );
Return ($ iVersion> = 5.5 );
} Else if (strpos ($ sAgent, 'Gecko /')! = False ){
$ IVersion = (int) substr ($ sAgent, strpos ($ sAgent, 'Gecko/') + 6, 8 );
Return ($ iVersion> = 20030210 );
} Else {
Return false;
}
}
For more details, see: http://www.111cn.net/phper/18/e6800bfcf8106373d02b9c7d8af118dc.htm