0

$agent = $_SERVER['HTTP_USER_AGENT'];

if(preg_match('/iPhone/i', $agent)){
    echo "You're using Iphone";
} else if(preg_match('/Android/i', $agent)){
    echo "You're using Iphone";
} else if(preg_match('/Blackberry/i', $agent)){
    echo "You're using Blackberry";
}

运行手机时的想法是型号名称,例如:Iphone => 显示型号是 Iphone 4S

4

1 回答 1

2

您可以使用名为WURFL的库来做到这一点。

这个这个,你可以很容易地做到:

$user_agent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; NOKIA; Lumia 800)";
$requestingDevice = $wurflManager->getDeviceForUserAgent($user_agent);
$is_wireless = ($requestingDevice->getCapability('is_wireless_device') == 'true');
$is_smarttv = ($requestingDevice->getCapability('is_smarttv') == 'true');
$is_tablet = ($requestingDevice->getCapability('is_tablet') == 'true');
$is_phone = ($requestingDevice->getCapability('can_assign_phone_number') == 'true');
于 2012-07-02T03:20:51.033 回答