首页 > php > PHP 判断客户端是IOS还是Android

PHP 判断客户端是IOS还是Android

2017年11月3日
<?php

//Detect special conditions devices
$iPod    = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iPhone  = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$iPad    = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
$Android = stripos($_SERVER['HTTP_USER_AGENT'],"Android");
$webOS   = stripos($_SERVER['HTTP_USER_AGENT'],"webOS");

//do something with this information
if( $iPod || $iPhone ){
    //browser reported as an iPhone/iPod touch -- do something here
}else if($iPad){
    //browser reported as an iPad -- do something here
}else if($Android){
    //browser reported as an Android device -- do something here
}else if($webOS){
    //browser reported as a webOS device -- do something here
}

?>

参考资料:
https://stackoverflow.com/questions/6322112/check-if-php-page-is-accessed-from-an-ios-device

声明:未作说明,则本文为php教程分享网站原创。转载务必注明出处。
谢谢!

分类: php 标签:


标签

ajax apache array array_slice CentOS checkbox composer cookie csv curl date DATE_FORMAT excel FCKEditor file_get_contents laravel Magento Certified Developer mb_substr memcache Memcached MySQL String Functions Netbeans openssl php面试题 preg_match_all preg_replace QQ登录 rewrite SaeStorage serialize session setTimeout Sphinx spl Storage strtotime ueditor vsftp vsftpd Zend zip 分割字符串 图片处理 新浪云 正则表达式

存档