Home  >  Article  >  Backend Development  >  PHP distinction Enterprise WeChat browser | Ordinary WeChat browser | Other browsers

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

不言
不言Original
2018-04-28 14:14:112106browse

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 '不是普通微信浏览器';
}

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 '不是企业微信浏览器';
}


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'];

       

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!

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