Home Backend Development PHP Tutorial php gets browser kernel version

php gets browser kernel version

Mar 25, 2017 am 11:06 AM
php Kernel version Browser Obtain

php gets the browser kernel version

<?php
function getBrowser(){
    $agent=$_SERVER["HTTP_USER_AGENT"];
    if(strpos($agent,&#39;MSIE&#39;)!==false || strpos($agent,&#39;rv:11.0&#39;)) //ie11判断
    return "ie";
    else if(strpos($agent,&#39;Firefox&#39;)!==false)//火狐
    return "firefox";
    else if(strpos($agent,&#39;Chrome&#39;)!==false)//谷歌
    return "chrome";
    else if(strpos($agent,&#39;Opera&#39;)!==false)//opera
    return &#39;opera&#39;;
    else if((strpos($agent,&#39;Chrome&#39;)==false)&&strpos($agent,&#39;Safari&#39;)!==false)
    return &#39;safari&#39;;
   
}
 
function getBrowserVer(){
    if (empty($_SERVER[&#39;HTTP_USER_AGENT&#39;])){    //当浏览器没有发送访问者的信息的时候
        return &#39;unknow&#39;;
    }
    $agent= $_SERVER[&#39;HTTP_USER_AGENT&#39;];   
    if (preg_match(&#39;/MSIE\s(\d+)\..*/i&#39;, $agent, $regs))//IE浏览器版本号
        return $regs[1];
    elseif (preg_match(&#39;/FireFox\/(\d+)\..*/i&#39;, $agent, $regs))//火狐浏览器版本号return $regs[1];
    elseif (preg_match(&#39;/Opera[\s|\/](\d+)\..*/i&#39;, $agent, $regs))//opera浏览器版本号
        return $regs[1];
    elseif (preg_match(&#39;/Chrome\/(\d+)\..*/i&#39;, $agent, $regs))//谷歌浏览器版本号
       return $regs[1];
    elseif ((strpos($agent,&#39;Chrome&#39;)==false)&&preg_match(&#39;/Safari\/(\d+)\..*$/i&#39;, $agent, $regs))
        return $regs[1];
    else
        return &#39;unknow&#39;;
}
$a=(getBrowser());
$b=(getBrowserVer());
echo $a;//然后对变量进行判断等操作
echo $b;
?>
Copy after login

The above introduces php to get the browser kernel version, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related articles:

Mainstream browser kernel and JS engine

Browser kernel summary

Browser kernel information compilation

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

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1672
14
PHP Tutorial
1277
29
C# Tutorial
1257
24
How reliable is Binance Plaza? How reliable is Binance Plaza? May 07, 2025 pm 07:18 PM

Binance Square is a social media platform provided by Binance Exchange, aiming to provide users with a space to communicate and share information related to cryptocurrencies. This article will explore the functions, reliability and user experience of Binance Plaza in detail to help you better understand this platform.

The TOP5 of the safest exchanges in 2025: Black U's guide to avoid pits, the rule of 100% of funds to save lives The TOP5 of the safest exchanges in 2025: Black U's guide to avoid pits, the rule of 100% of funds to save lives May 08, 2025 pm 08:27 PM

In the field of cryptocurrency trading, the security of exchanges has always been the focus of users. In 2025, after years of development and evolution, some exchanges stand out with their outstanding security measures and user experience. This article will introduce the five most secure exchanges in 2025 and provide practical guides on how to avoid Black U (hacker attacks users) to ensure your funds are 100% secure.

2025 Binance Binance Exchange Latest Login Portal 2025 Binance Binance Exchange Latest Login Portal May 07, 2025 pm 07:03 PM

As the world's leading cryptocurrency exchange, Binance is always committed to providing users with a safe and convenient trading experience. Over time, Binance has continuously optimized its platform features and user interface to meet the changing needs of users. In 2025, Binance launched a new login portal aimed at further improving the user experience.

How to register in the ok exchange in China? ok trading platform registration and use guide for beginners in mainland China How to register in the ok exchange in China? ok trading platform registration and use guide for beginners in mainland China May 08, 2025 pm 10:51 PM

In the cryptocurrency market, choosing a reliable trading platform is crucial. As a world-renowned digital asset exchange, the OK trading platform has attracted a large number of novice users in mainland China. This guide will introduce in detail how to register and use it on the OK trading platform to help novice users get started quickly.

The latest entrance address of Binance Exchange in 2025 The latest entrance address of Binance Exchange in 2025 May 07, 2025 pm 07:00 PM

As the world's leading cryptocurrency exchange, Binance is always committed to providing users with a safe and convenient trading experience. Over time, Binance has continuously optimized its platform features and user interface to meet the changing needs of users. In 2025, Binance launched a new login portal aimed at further improving the user experience.

Best Practices for Dependency Injection in PHP Best Practices for Dependency Injection in PHP May 08, 2025 am 12:21 AM

The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

2025 Binance Online Web Address 2025 Binance Online Web Address May 07, 2025 pm 06:54 PM

As the world's leading cryptocurrency exchange, Binance is always committed to providing users with a safe and convenient trading experience. Over time, Binance has continuously optimized its platform features and user interface to meet the changing needs of users. In 2025, Binance launched a new login portal aimed at further improving the user experience.

Detailed Guide to Installation and Registration of Binance Binance Exchange (2025 Latest Steps) Detailed Guide to Installation and Registration of Binance Binance Exchange (2025 Latest Steps) May 08, 2025 pm 11:06 PM

Binance is one of the world's leading cryptocurrency trading platforms, providing trading services for a variety of digital assets. If you are considering using Binance for cryptocurrency trading, this article will provide you with a detailed installation and registration guide.

See all articles