Home > php教程 > php手册 > body text

php判断浏览器类型代码

WBOY
Release: 2016-06-06 20:07:34
Original
1341 people have browsed it

这是第一篇博文,庆祝千娱千寻网团队博客上线! 这篇文章没有什么不同,主要测试博客文章页面的样式,特别是代码高亮显示,顺便总结下用php判断浏览器的方法。 ?phpif(strpos($_SERVER["HTTP_USER_AGENT"],'MSIE 8.0'))echo 'Internet Explorer 8.0'; else i

这是第一篇博文,庆祝千娱千寻网团队博客上线!

这篇文章没有什么不同,主要测试博客文章页面的样式,特别是代码高亮显示,顺便总结下用php判断浏览器的方法。

<?php if(strpos($_SERVER["HTTP_USER_AGENT"],'MSIE 8.0'))
	echo 'Internet Explorer 8.0'; 
else if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE 7.0'))
	echo 'Internet Explorer 7.0';
else if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE 6.0'))
	echo 'Internet Explorer 6.0';
else if(strpos($_SERVER['HTTP_USER_AGENT'],'Firefox/3'))
	echo 'Firefox 3';
else if(strpos($_SERVER['HTTP_USER_AGENT'],'Firefox/2'))
	echo 'Firefox 2';
else if(strpos($_SERVER['HTTP_USER_AGENT'],'Chrome'))
	echo 'Google Chrome';
else if(strpos($_SERVER['HTTP_USER_AGENT'],'Safari'))
	echo 'Safari';
else if(strpos($_SERVER['HTTP_USER_AGENT'],'Opera'))
	echo 'Opera';
else echo $_SERVER['HTTP_USER_AGENT']; 
?>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template