PHP和JS判断浏览器是微信还是支付宝
时间:2018-05-02 16:08:07
收藏:0
阅读:1616
PHP代码
if ( strpos($_SERVER[‘HTTP_USER_AGENT‘], ‘MicroMessenger‘) !== false ) {
return ‘WeiXin’;
}
//判断是不是支付宝
if (strpos($_SERVER[‘HTTP_USER_AGENT‘], ‘AlipayClient‘) !== false) {
return "AliPay";
}
JS判断
function WxOrAli(){
var ua = window.navigator.userAgent.toLowerCase();
//判断是不是微信
if ( ua.match(/MicroMessenger/i) == ‘micromessenger‘ ) {
return "WeiXIN";
}
//判断是不是支付宝
if (ua.match(/AlipayClient/i) == ‘alipayclient‘) {
return "Alipay";
}
//哪个都不是
return "false";
}
评论(0)