Press "Enter" to skip to content

PHP判断客户端是否是微信浏览器

$user_agent = $_SERVER[‘HTTP_USER_AGENT’];
if (strpos($user_agent, ‘MicroMessenger’) === false){
echo ‘非微信浏览器禁止浏览’;
return false;
}else{
echo ‘微信浏览器,允许访问’;
preg_match(‘/.*?(MicroMessenger\/([0-9.]+))\s*/’, $user_agent, $matches);
echo ‘<br>你的微信版本号为:’.$matches[2];

}

发表评论