search
HomeBackend DevelopmentPHP TutorialGet the user's browser and version information

<span>function </span><span>determinebrowser () {
</span><span>$agent </span><span>= </span><span>isset</span><span>(</span><span>$_SERVER</span><span>[</span><span>'HTTP_USER_AGENT'</span><span>]) ? </span><span>$_SERVER</span><span>[</span><span>'HTTP_USER_AGENT'</span><span>] : </span><span>'' </span><span>;
</span><span>$browseragent </span><span>= </span><span>""</span><span>;   </span><span><em>//</em></span><span><em>浏览器
</em></span><span><em></em></span><span>$browserversion </span><span>= </span><span>""</span><span>; </span><span><em>//</em></span><span><em>浏览器的版本
</em></span><span><em></em></span><span>if </span><span>(</span><span><em>preg_match</em></span><span>(</span><span>'/360SE/i'</span><span>,</span><span>$agent</span><span>)) {
</span><span>$browserversion </span><span>= </span><span>''</span><span>;
</span><span>$browseragent </span><span>= </span><span>"360</span><span>浏览器</span><span>"</span><span>;
</span><span>    } </span><span>else if</span><span>(</span><span><em>preg_match</em></span><span>(</span><span>'/Maxthon (([0-9_.]{1,2}+))/i'</span><span>,</span><span>$agent</span><span>,</span><span>$version</span><span>)){
</span><span>$browserversion </span><span>= </span><span>$version</span><span>[</span><span>1</span><span>];
</span><span>$browseragent </span><span>= </span><span>"Maxthon"</span><span>;
</span><span>    }</span><span>else if </span><span>(</span><span><em>preg_match</em></span><span>(</span><span>'/MSIE (([0-9_.]{1,2})+)/i'</span><span>,</span><span>$agent</span><span>,</span><span>$version</span><span>)) {
</span><span>$browserversion </span><span>= </span><span>$version</span><span>[</span><span>1</span><span>];
</span><span>$browseragent </span><span>= </span><span>"Internet Explorer"</span><span>;
</span><span>    } </span><span>else if </span><span>(</span><span><em>preg_match</em></span><span>( </span><span>'/iOpera\/(([0-9_.]{1,2})+)/i'</span><span>,</span><span>$agent</span><span>,</span><span>$version</span><span>)) {
</span><span>$browserversion </span><span>= </span><span>$version</span><span>[</span><span>1</span><span>];
</span><span>$browseragent </span><span>= </span><span>"Opera"</span><span>;
</span><span>    } </span><span>else if </span><span>(</span><span><em>preg_match</em></span><span>( </span><span>'/Firefox\/(([0-9_.]{1,3})+)/i'</span><span>,</span><span>$agent</span><span>,</span><span>$version</span><span>)) {
</span><span>$browserversion</span><span>=</span><span>$version</span><span>[</span><span>1</span><span>];
</span><span>$browseragent </span><span>= </span><span>"Firefox"</span><span>;
</span><span>    } </span><span>else if </span><span>(</span><span><em>preg_match</em></span><span>( </span><span>'/Chrome\/(([0-9_.]{1,5})+)/i'</span><span>,</span><span>$agent</span><span>,</span><span>$version</span><span>)) {
</span><span>$browserversion </span><span>= </span><span>$version</span><span>[</span><span>1</span><span>];
</span><span>$browseragent </span><span>= </span><span>"Chrome"</span><span>;
</span><span>    } </span><span>else if </span><span>(</span><span><em>preg_match</em></span><span>( </span><span>'/Safari\/(([0-9_.]{1,5})+)/'</span><span>,</span><span>$agent</span><span>,</span><span>$version</span><span>)) {
</span><span>$browserversion </span><span>= </span><span>$version</span><span>[</span><span>1</span><span>];
</span><span>$browseragent </span><span>= </span><span>"Safari"</span><span>;
</span><span>    } </span><span>else </span><span>{
</span><span>$browserversion </span><span>= </span><span>""</span><span>;
</span><span>$browseragent </span><span>= </span><span>"Unknown"</span><span>;
</span><span>    }
</span><span>return </span><span>$browseragent</span><span>.</span><span>" "</span><span>.</span><span>$browserversion</span><span>;
</span><span>}</span>

The above introduces how to obtain the user's browser and version information, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement
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
复旦NLP团队发布80页大模型Agent综述,一文纵览AI智能体的现状与未来复旦NLP团队发布80页大模型Agent综述,一文纵览AI智能体的现状与未来Sep 23, 2023 am 09:01 AM

近期,复旦大学自然语言处理团队(FudanNLP)推出LLM-basedAgents综述论文,全文长达86页,共有600余篇参考文献!作者们从AIAgent的历史出发,全面梳理了基于大型语言模型的智能代理现状,包括:LLM-basedAgent的背景、构成、应用场景、以及备受关注的代理社会。同时,作者们探讨了Agent相关的前瞻开放问题,对于相关领域的未来发展趋势具有重要价值。论文链接:https://arxiv.org/pdf/2309.07864.pdfLLM-basedAgent论文列表:

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code<form name="myform"

Java Agent怎么用Java Agent怎么用May 22, 2023 pm 08:52 PM

JavaAgent技术简介JavaAgent直译为Java代理,也常常被称为Java探针技术。JavaAgent是在JDK1.5引入的,是一种可以动态修改Java字节码的技术。Java中的类编译后形成字节码被JVM执行,在JVM在执行这些字节码之前获取这些字节码的信息,并且通过字节码转换器对这些字节码进行修改,以此来完成一些额外的功能。JavaAgent是一个不能独立运行jar包,它通过依附于目标程序的JVM进程,进行工作。启动时只需要在目标程序的启动参数中添加-javaagent参数添加Cla

优秀Agent智能体必学的几种设计模式,一学就会优秀Agent智能体必学的几种设计模式,一学就会May 30, 2024 am 09:44 AM

大家好,我是老渡。昨天在公司听了清华大学智能产业研究院现场分享的AI医院小镇。图片这是一个虚拟世界,所有的医生、护士、患者都是由LLM驱动的Agent智能体,可以自主交互。它们模拟了整个诊病看病的过程,在浸盖主要呼吸道疾病的MedQA数据集子集上,实现了高达93.06%的最新准确率。一个优秀的智能体,离不开优秀的设计模式。看完这个案例,我赶紧拜读了吴恩达老师最近发表的4种主要的Agent设计模式。吴恩达是人工智能和机器学习领域国际上最权威的学者之一然后,赶紧整理出来,跟大家分享一下。模式一、反思

不用数据库来实现用户的简单的下载,代码如下,但是却不能下载,请高手找下原因,文件路劲什么的没有关问题不用数据库来实现用户的简单的下载,代码如下,但是却不能下载,请高手找下原因,文件路劲什么的没有关问题Jun 13, 2016 am 10:15 AM

不用数据库来实现用户的简单的下载,代码如下,但是却不能下载,请高手找下原因,文件路劲什么的没问题。<?phpfunction down_file($file_name,$file_sub_dir){//为防止乱码使用函数iconv$file_name=iconv("utf-8","gb2312",$file_

为什么小弟我在php上写的这个代码,在浏览器上什么都不显示为什么小弟我在php上写的这个代码,在浏览器上什么都不显示Jun 13, 2016 am 10:24 AM

为什么我在php上写的这个代码,在浏览器上什么都不显示啊<?php   if(isset($_POST['Submit'])&& $_POST['Submit']=="登陆"){   $user=$_POST['user']; $pass=$_POST['pass']; if(empt

图片消失怎么解决图片消失怎么解决Apr 07, 2024 pm 03:02 PM

图片消失如何解决先是图片文件上传$file=$_FILES['userfile'];  if(is_uploaded_file($file['tmp_name'])){$query=mysql_query("INSERT INTO gdb_banner(image_src ) VALUES ('images/{$file['name'

图片消失怎么解决图片消失怎么解决Jun 13, 2016 am 10:09 AM

图片消失如何解决先是图片文件上传$file=$_FILES['userfile'];  if(is_uploaded_file($file['tmp_name'])){$query=mysql_query("INSERT INTO gdb_banner(image_src ) VALUES ('images/{$file['name'

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor