下面来为各位整理一段php判断是Android还是Ios还是Pc的访问网站例子,非常 的实用希望对各位朋友会有所帮助.
function strexists($string, $find) { return !(strpos($string, $find) === false); }
function deep_in_array($value, $array) {
foreach($array as $item) {
if(!is_array($item)) {
if (strpos($value, $item) !== false) {
return true;
} else { continue; } }
if(in_array($value, $item)) {
return true;
} else if(deep_in_array($value, $item)) {
return true;
}
} return false; }
function mobile() {
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
$ualist = array('android', 'midp', 'nokia', 'mobile', 'iphone', 'ipod', 'blackberry', 'windows phone');
if((deep_in_array($useragent, $ualist) || strexists($_SERVER['HTTP_ACCEPT'], "VND.WAP") || strexists($_SERVER['HTTP_VIA'],"wap")))
if(strpos($useragent,'iphone')!==false||strpos($useragent,'ipod')!==false) return '苹果'; else return '安卓';
else
return '电脑'; }
评论