PHP distinction Enterprise WeChat browser | Ordinary WeChat browser | Other browsers

不言
Release: 2023-03-25 06:54:02
Original
2292 people have browsed it

This article mainly introduces how PHP distinguishes enterprise WeChat browsers, ordinary WeChat browsers, and other browsers. It has certain reference value. Now it is shared with everyone. Friends in need can refer to it

Often when we are working on projects in the WeChat environment, we need to determine whether the terminal accessed by the current user is accessed within WeChat. At this time, we need to determine whether the current browser is a WeChat browser. The code is as follows:

if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false ) {
    echo '普通微信浏览器';
} else {
    echo '不是普通微信浏览器';
}
Copy after login

If the project environment is In Enterprise WeChat, the Enterprise WeChat browser is different from the ordinary WeChat browser, so it still needs to be judged. The code is as follows:

// 判断是否是企业微信内嵌浏览器
if ( strpos($_SERVER['HTTP_USER_AGENT'] , 'wxwork') !== false ) {
    echo '企业微信浏览器';
} else {
    echo '不是企业微信浏览器';
}
Copy after login


When encountering projects that require judgment of the browser , you can use the following code to print the current browser information:

echo $_SERVER['HTTP_USER_AGENT'];
Copy after login

       

The above is the detailed content of PHP distinction Enterprise WeChat browser | Ordinary WeChat browser | Other browsers. For more information, please follow other related articles on the PHP Chinese website!

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template