欢迎光临
我们一直在努力

转|PHP判断用户访问的操作系统,以及iOS的设备

如今上网的渠道是越来越多了,不再局限于PC互联网端了,如今使用的手机上网,IPAD,IPHONE等等也作为了主流,除了上网的客户端变得多样外,还有用户的操作系统也变得多样,虽然windows还是主流,但是现在还有比较专业的设计人员用的是mac,另外手机操作系统 android 也是作为手机主流操作系统来供用户来访问的。

既然上网的渠道变得多样化,用户使用的操作系统和设备也多了起来,这些终端的信息对于我们用户来说并没哪么重要,我们只要可以用来上网就行了,体验好就可以,但这些信息对于专业的SEO人员或者是数据分析师来说,却是不可缺少的,因为只有通过了解用户通过什么方式,什么渠道进入到我们的产品站点或者是 产品APP,当整个数据都一目明了的时候,我们就可以进行对产品进行有效的广告投放,当然这个只是简单的获取访问的操作系统和IOS的设备,更详细的还可以进行获取访问人数的年龄,地域,性别等等,这里就不再进行更为详细的介绍了。

那么下面仅是一个简单的PHP判断用户访问的操作系统,以及IOS设备的PHP实例函数,其中集成了 windows nt,mac,ipod,ipad等主流系统和IOS设备,可以根据自己的情况进行修改,将其函数直接包含到 php 页面中即可返回相应信息。

function getOS()
{
$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;
}

分享到: 更多 (0)

点击此处获取更多金融后续培训参考答案

相关推荐

  • PHP分页代码函数-侯建方的个人网站PHP分页代码函数

  • Notice: Undefined index: taxonomy in /data/wwwroot/houjianfang.com/wp-content/plugins/wpjam-basic/public/wpjam-thumbnail.php on line 84

    Notice: Undefined index: post_meta in /data/wwwroot/houjianfang.com/wp-content/plugins/wpjam-basic/public/wpjam-thumbnail.php on line 78

    Notice: Undefined index: taxonomy in /data/wwwroot/houjianfang.com/wp-content/plugins/wpjam-basic/public/wpjam-thumbnail.php on line 84

    Notice: Undefined index: post_meta in /data/wwwroot/houjianfang.com/wp-content/plugins/wpjam-basic/public/wpjam-thumbnail.php on line 78
    php的多态实现-侯建方的个人网站php的多态实现

  • Notice: Undefined index: taxonomy in /data/wwwroot/houjianfang.com/wp-content/plugins/wpjam-basic/public/wpjam-thumbnail.php on line 84

    Notice: Undefined index: post_meta in /data/wwwroot/houjianfang.com/wp-content/plugins/wpjam-basic/public/wpjam-thumbnail.php on line 78

    Notice: Undefined index: taxonomy in /data/wwwroot/houjianfang.com/wp-content/plugins/wpjam-basic/public/wpjam-thumbnail.php on line 84

    Notice: Undefined index: post_meta in /data/wwwroot/houjianfang.com/wp-content/plugins/wpjam-basic/public/wpjam-thumbnail.php on line 78
    wordpress英文主题截取中文不显示-侯建方的个人网站wordpress英文主题截取中文不显示
  • PHP中使用CURL实现GET、POST、PUT、DELETE请求-侯建方的个人网站PHP中使用CURL实现GET、POST、PUT、DELETE请求

  • Notice: Undefined index: taxonomy in /data/wwwroot/houjianfang.com/wp-content/plugins/wpjam-basic/public/wpjam-thumbnail.php on line 84

    Notice: Undefined index: post_meta in /data/wwwroot/houjianfang.com/wp-content/plugins/wpjam-basic/public/wpjam-thumbnail.php on line 78

    Notice: Undefined index: taxonomy in /data/wwwroot/houjianfang.com/wp-content/plugins/wpjam-basic/public/wpjam-thumbnail.php on line 84

    Notice: Undefined index: post_meta in /data/wwwroot/houjianfang.com/wp-content/plugins/wpjam-basic/public/wpjam-thumbnail.php on line 78
    ionic项目中列表显示不同模板-侯建方的个人网站ionic项目中列表显示不同模板

  • Notice: Undefined index: taxonomy in /data/wwwroot/houjianfang.com/wp-content/plugins/wpjam-basic/public/wpjam-thumbnail.php on line 84

    Notice: Undefined index: post_meta in /data/wwwroot/houjianfang.com/wp-content/plugins/wpjam-basic/public/wpjam-thumbnail.php on line 78

    Notice: Undefined index: taxonomy in /data/wwwroot/houjianfang.com/wp-content/plugins/wpjam-basic/public/wpjam-thumbnail.php on line 84

    Notice: Undefined index: post_meta in /data/wwwroot/houjianfang.com/wp-content/plugins/wpjam-basic/public/wpjam-thumbnail.php on line 78
    php数据库操作类-侯建方的个人网站php数据库操作类

  • Notice: Undefined index: taxonomy in /data/wwwroot/houjianfang.com/wp-content/plugins/wpjam-basic/public/wpjam-thumbnail.php on line 84

    Notice: Undefined index: post_meta in /data/wwwroot/houjianfang.com/wp-content/plugins/wpjam-basic/public/wpjam-thumbnail.php on line 78

    Notice: Undefined index: taxonomy in /data/wwwroot/houjianfang.com/wp-content/plugins/wpjam-basic/public/wpjam-thumbnail.php on line 84

    Notice: Undefined index: post_meta in /data/wwwroot/houjianfang.com/wp-content/plugins/wpjam-basic/public/wpjam-thumbnail.php on line 78
    JS一维数组、多维数组和对象的混合使用-侯建方的个人网站JS一维数组、多维数组和对象的混合使用
  • 被遗忘的HTML标签fieldset-侯建方的个人网站被遗忘的HTML标签fieldset