PHP:检测Android设备的名称? [英] PHP: detect name of android device?

查看:28
本文介绍了PHP:检测Android设备的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何检测访问者在 PHP 中使用的 Android 设备,例如.Galaxy S. 在用手机浏览 facebook 时,我看到:在您的 Galaxy S 上安装 Facebook 并加快浏览速度"

I want to know how I can detect the Android device the visitor uses in PHP, for eg. Galaxy S. While browsing facebook from my phone, I saw: "Install Facebook on your Galaxy S and browse faster"

于是我查看了phpinfo();位于我在浏览 facebook 时使用的同一浏览器的服务器上,搜索galaxy"文本但没有匹配项.那么它是如何检测到我的设备名称的呢?以及如何在我的 PHP 脚本中检测到它?

So I viewed phpinfo(); located on my server from the same browser I used while browsing facebook and searched for "galaxy" text and got no matches. So how come it detected my device name? And how can I detect it on my PHP script?

任何帮助将不胜感激.

推荐答案

在这里找到了类似的东西:- http://forums.macrumors.com/showthread.php?t=205417

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

检查它是否对您有用.

<?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'];
}
?>

这里还有一些东西:- http://mobiledetect.net/

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

还有一些:- http://detectmobilebrowsers.mobi/

干杯!

这篇关于PHP:检测Android设备的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆