PHP: detect name of android device?

吃可爱长大的小学妹 提交于 2019-12-03 21:53:21

Found something like this in here :- http://forums.macrumors.com/showthread.php?t=205417

Check whether it's useful for you not.

<?php
/* detect mobile device*/
$ismobile = 0;
$container = $_SERVER['HTTP_USER_AGENT'];
// A list of mobile devices 
$useragents = array ( 
'Blazer' ,
'Palm' ,
'Handspring' ,
'Nokia' ,
'Kyocera',
'Samsung' ,
'Motorola' ,
'Smartphone', 
'Windows CE' ,
'Blackberry' ,
'WAP' ,
'SonyEricsson',
'PlayStation Portable', 
'LG', 
'MMP',
'OPWV',
'Symbian',
'EPOC',
); 

foreach ( $useragents as $useragents ) { 
 if(strstr($container,$useragents)) {
   $ismobile = 1;
 }
}
if ( $ismobile == 1 ) {
echo "<p>mobile device</p>";
echo $_SERVER['HTTP_USER_AGENT'];
}
?>

Some more stuffs here in here :- http://mobiledetect.net/

And some more :- http://detectmobilebrowsers.mobi/

Cheers!

Use the superglobal $_SERVER.

$useragent = $_SERVER['HTTP_USER_AGENT'];
$info = get_browser($useragent);

For further information about the result of get_browser see the doku here: http://de2.php.net/manual/en/function.get-browser.php
Most important for your purpous I guess would be $info->platform.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!