<?php $useragent = addslashes($_SERVER['HTTP_USER_AGENT']); if(strpos($useragent, 'MicroMessenger') === false && strpos($useragent, 'Windows Phone') === false ){ echo " 非微信浏览器禁止访问www.buyerinfo.biz"; }else{ echo "微信浏览器,允许访问YES"; preg_match("/.*?(MicroMessenger\/([0-9.]+))\s*/",$useragent, $matches); echo "你的微信版本号为:".$matches[2]; } ?>