电脑安全

您当前的位置:主页 > 电脑安全 >

php获取访问者浏览页面的浏览器类型-网络编程

来源:[db:来源]标题:   浏览器    编辑:电脑技术全能网 时间:2019-09-22 12:31

原标题:php获取访问者浏览页面的浏览器类型-网络编程
   近来做的名目须要依据用户扫瞄器的范例而做一些差别的处置,因而略微研讨了一下应用php推断扫瞄器范例的方式,这里分享给各人,供各人进修参考 方式以下检讨用户的agent字符串,它是扫瞄器发送的HTTP恳求的一局部。用$_SERVER['HTTP_USER_AGENT']失掉agent字符串信息。比方: 代码以下复制代码 <?phpecho$_SERVER['HTTP_USER_AGENT'];?>有能够是打印出如许的:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)封装成函数: 代码以下复制代码 functionmy_get_browser(){if(empty($_SERVER['HTTP_USER_AGENT'])){return'robot!';}if( (false ==strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')) && (strpos($_SERVER['HTTP_USER_AGENT'],'Trident')!==FALSE) ){return'Internet Explorer 11.0';}if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'MSIE 10.0')){return'Internet Explorer 10.0';}if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'MSIE 9.0')){return'Internet Explorer 9.0';}if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'MSIE 8.0')){return'Internet Explorer 8.0';}if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'MSIE 7.0')){return'Internet Explorer 7.0';}if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'MSIE 6.0')){return'Internet Explorer 6.0';}if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'Edge')){return'Edge';}if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'Firefox')){return'Firefox';}if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'Chrome')){return'Chrome';}if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'Safari')){return'Safari';}if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'Opera')){return'Opera';}if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'360SE')){return'360SE';}//微信扫瞄器if(false!==strpos($_SERVER['HTTP_USER_AGENT'],'MicroMessage')){return'MicroMessage';}>}

上一篇:PHP网络编程:创建登录表单-网络编程

下一篇:没有了