This time I will bring you PHPWhat are the precautions to 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 "来自微信浏览器访问"; }
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!