PHP determines from which channel to open the QR code

php中世界最好的语言
Release: 2023-03-26 14:12:01
Original
2161 people have browsed it

This time I will bring youPHPWhat are theprecautionsto determine from which channel to open the QR code and PHP to determine from which channel to open the QR code? 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 a browser identifier, with some customer information. For example, the browser kernel, operating system, etc.

WeChat access to the web page is also a browser, 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:

How to operate phpstudy2018 to access directory service permissions

ThinkPHP Detailed explanation of the steps to implement WeChat payment (jsapi payment)

The above is the detailed content of PHP determines from which channel to open the QR code. 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
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!