PHP判断访问设备类型
/**
* 用户设备类型
* @return string
*/
function clientOS() {
$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
if(strpos($agent, 'windows nt')) {
$platform = 'windows';
} elseif(strpos($agent, 'macintosh')) {
$platform = 'mac';
} elseif(strpos($agent, 'ipod')) {
$platform = 'ipod';
} elseif(strpos($agent, 'ipad')) {
$platform = 'ipad';
} elseif(strpos($agent, 'iphone')) {
$platform = 'iphone';
} elseif (strpos($agent, 'android')) {
$platform = 'android';
} elseif(strpos($agent, 'unix')) {
$platform = 'unix';
} elseif(strpos($agent, 'linux')) {
$platform = 'linux';
} else {
$platform = 'other';
}
return $platform;
}