请求接口的客户端类型判断

1
2
3
4
5
6
7
8
9
10
11
12
$userAgent = $_SERVER['HTTP_USER_AGENT'];
if (preg_match("/(iPod|iPad|iPhone)/", $userAgent))
{
$type = 1; //IOS客户端
}
elseif (preg_match("/WP/", $userAgent))
{
$type = 2; //WinPhone客户端
}
elseif (preg_match("/android/i", $userAgent)) {
$type = 3; //android客户端
}