PHP determines whether WeChat is opened or the browser is opened

php中世界最好的语言
Release: 2023-03-22 06:50:01
Original
4021 people have browsed it

This time I will bring you PHPJudge whether WeChat is opened or the browser is opened, PHP determines whether WeChat is opened or the browser is openedWhat are the precautions, the following is a practical case , let’s take a look.

#Problem

Problems encountered in the project, if the user accesses using WeChat.

Then make it friendly Tips"How to open with a browser/Tell the user to open with a browser"

Solution

useragent is the browser identifier, with some customer information. For example, the browser kernel, operating system, etc.

WeChat access to the web page is also a browser, and it also has a UA. Then you can identify it by judging its UA. Whether it has been visited by WeChat

$ua = $_SERVER['HTTP_USER_AGENT']; 
//MicroMessenger 是android/iphone版微信所带的
//Windows Phone 是winphone版微信带的 (这个标识会误伤winphone普通浏览器的访问)
if(strpos($ua, 'MicroMessenger') == false || strpos($ua, 'Windows Phone') == false){ 
 echo "来自普通浏览器访问"; 
}else{ 
 echo "来自微信浏览器访问"; 
}
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Mysqld_multi deployment stand-alone detailed explanation

Summary of some MySQL traps

The reason why the installation of mysql service failed to start

How to operate the table in Bootstrap

The above is the detailed content of PHP determines whether WeChat is opened or the browser is opened. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!