php判断手机是安卓系统还是ios系统
jopen
9年前
function get_device_type()
{
//全部变成小写字母
$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
$type ='other';
//分别进行判断
if(strpos($agent,'iphone') || strpos($agent,'ipad'))
{
$type ='ios';
}
if(strpos($agent,'android'))
{
$type ='android';
}
return$type;
}
</span>
php判断页面是否是微信打开
$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];
}