相争不足 共享有余

php判断微信客户端or pc电脑端or ipad端

编程开发 moonygao 1780℃ 0评论

if(strpos($_SERVER[‘HTTP_USER_AGENT’], ‘iPhone’)||strpos($_SERVER[‘HTTP_USER_AGENT’], ‘iPad’)){
echo ‘systerm is IOS’;
}else if(strpos($_SERVER[‘HTTP_USER_AGENT’], ‘Android’)){
echo ‘systerm is Android’;
}else{
echo ‘systerm is other’;
}

//是否是微信端
echo ‘<br/>’;
$user_agent = $_SERVER[‘HTTP_USER_AGENT’];
if (strpos($user_agent, ‘MicroMessenger’) === false) {
// 非微信浏览器禁止浏览
echo “HTTP/1.1 401 Unauthorized”;
} else {
// 微信浏览器,允许访问
echo “MicroMessenger”;
// 获取版本号
preg_match(‘/.*?(MicroMessenger\/([0-9.]+))\s*/’, $user_agent, $matches);
echo ‘<br>Version:’.$matches[2];
}

转载请注明:IT起义 » php判断微信客户端or pc电脑端or ipad端

喜欢 (0)or分享 (0)