我正在使用Mobile_Detect来查找OS
客户端使用的,我厌倦了这段代码
function get(){
$user_agent = $this->mobile_detect->getUserAgent();
foreach($this->mobile_detect->getOperatingSystems() as $os)
{
if(preg_match('/('.$os.')/i',$user_agent,$matches))
{
$dev = '';
for($i=0;i<count($matches);$i++){ $dev.=$matches[$i];}
$registration_os = $dev;
}
}
print_r($registration_os);
}
$this->mobile_detect->getOperatingSystems()
返回数组
Array
(
[AndroidOS] => Android
[BlackBerryOS] => blackberry|\bBB10\b|rim tablet os
[PalmOS] => PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino
[SymbianOS] => Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b
[WindowsMobileOS] => Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;
[WindowsPhoneOS] => Windows Phone OS|XBLWP7|ZuneWP7
[iOS] => \biPhone.*Mobile|\biPod|\biPad
[MeeGoOS] => MeeGo
[MaemoOS] => Maemo
[JavaOS] => J2ME/|Java/|\bMIDP\b|\bCLDC\b
[webOS] => webOS|hpwOS
[badaOS] => \bBada\b
[BREWOS] => BREW
)
但这不起作用,知道如何得到这个吗?