php 判断是否是手机浏览器访问

ggp php 2014-01-29 415 次浏览

$ua = strtolower($_SERVER[’HTTP_USER_AGENT’]);

$uachar = “/(nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|mobile)/i”;

if(($ua == ’’ || preg_match($uachar, $ua))&& !strpos(strtolower($_SERVER[’REQUEST_URI’]),’wap’))
{
$Loaction = ’mobile/’;

if (!empty($Loaction))
{
ecs_header(“Location: $Loaction
“);

exit;
}

}

回顶部