This article mainly introduces PHP to determine whether the mobile phone is iOS or Android three methods, interested in a friend's reference, I hope to be helpful to everyone.
Example 1: The main purpose is to use the http_user_agent, which means to check the browsing page of the visitors using what operating system (including version number) browser (including version number) and user preferences of the code.
The monitoring code is as follows:
function Get_device_type () {//all becomes lowercase $agent = strtolower ($_server[' http_user_agent ')), $type = ' other '; Strpos ($agent, ' iphone ') | | Strpos ($agent, ' ipad ') {$type = ' iOS ';} if (Strpos ($agent, ' Android ')) {$type = ' Android ';} return $type;}
By calling Objective-c This function, you can get the type of the phone.
Example 2: just need a judgment.
<?phpif (Strpos ($_server[' http_user_agent '), ' IPhone ') | | Strpos ($_server[' http_user_agent '), ' IPad ') {echo ' systerm is IOS ';} else if (Strpos ($_server[' http_user_agent '), ' Android ') {echo ' systerm is Android ';} else{Echo ' systerm is Other ';}? >
Example 3: This example may be a bit tricky but it's shared with everyone.
function Get_device_type () {//all becomes lowercase $agent = strtolower ($_server[' http_user_agent ')), $type = ' other '; Strpos ($agent, ' iphone ') | | Strpos ($agent, ' ipad ') {$type = ' iOS ';} if (Strpos ($agent, ' Android ')) {$type = ' Android ';} Return$type;}
Summary: The above is the entire content of this article, I hope to be able to help you learn.