PHP to determine whether the phone is an Android or iOS system

Source: Internet
Author: User

recent projects, to determine whether the user's mobile phone is Android or iOS, search the relevant information, the final results obtained. It turns out that it's effective! The main thing is to use the http_user_agent, which means the code used to check the browser (including version number) and user preferences of the visitor on the browsing page.

The monitoring code is as follows:

function Get_device_type ()
{
All into lowercase letters
$agent = Strtolower ($_server[' http_user_agent ');
$type = ' other ';
To judge separately.
if (Strpos ($agent, ' iphone ') | | strpos ($agent, ' ipad '))
{
$type = ' iOS ';
}

if (Strpos ($agent, ' Android '))
{
$type = ' Android ';
}
return $type;
}

By calling this function, you can get the type of the phone.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

PHP to determine whether the phone is an Android or iOS system

Related Article

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.