原理是判断浏览器提交的USER AGENT,代码如下:
如果你只判断是否为iphone设备可以如下来进行操作,代码如下:
function get_device_type(){
$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
$type = 'other';
if(strpos($agent, 'iphone') || strpos($agent, 'ipad') ){
$type = 'ios';
}
if(strpos($agent, 'android')){
$type = 'android';
}
return $type;
}