经测试代码如下:
/**
* iphone、android设备输出不同的viewport
*
* @param
* @arrange (512.笔记) jb51.cc
**/
//if iphone
$browser = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
if ($browser == true){
$browser = 'iphone';
}
//if android
$android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");
if ($android == true){
$android = 'android';
}
<?PHP if ($browser == 'iphone') { ?>
<Meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0" />
<?PHP } elseif ($android == 'android') { ?>
<Meta name="HandheldFriendly" content="true" />
<Meta name="viewport" content="width=device-width,height=device-height,user-scalable=no" />
<?PHP } ?>
/*** 来自编程之家 jb51.cc(jb51.cc) ***/
原文链接:https://www.f2er.com/php/528975.html