function isMobile()
{
// 如果有HTTP_X_WAP_PROFILE則一定是移動裝置
if (isset (KaTeX parse error: Double subscript at position 16: _SERVER['HTTP_X_̲WAP_PROFILE']))…_SERVER[‘HTTP_VIA’]))
{
// 找不到為flase,否則為true
return stristr(KaTeX parse error: Expected 'EOF', got '}' at position 49: …e : false; }̲ // 腦殘法,判斷…_SERVER[‘HTTP_USER_AGENT’]))
{
$clientkeywords = array (‘nokia’,
‘sony’,
‘ericsson’,
‘mot’,
‘samsung’,
‘htc’,
‘sgh’,
‘lg’,
‘sharp’,
‘sie-’,
‘philips’,
‘panasonic’,
‘alcatel’,
‘lenovo’,
‘iphone’,
‘ipod’,
‘blackberry’,
‘meizu’,
‘android’,
‘netfront’,
‘symbian’,
‘ucweb’,
‘windowsce’,
‘palm’,
‘operamini’,
‘operamobi’,
‘openwave’,
‘nexusone’,
‘cldc’,
‘midp’,
‘wap’,
‘mobile’
);
// 從HTTP_USER_AGENT中查找手機浏覽器的關鍵字
if (preg_match("/(" . implode(’|’, c l i e n t k e y w o r d s ) . " ) / i " , s t r t o l o w e r ( clientkeywords) . ")/i", strtolower( clientkeywords).")/i",strtolower(_SERVER[‘HTTP_USER_AGENT’])))
{
return true;
}
}
// 協定法,因為有可能不準确,放到最後判斷
if (isset (KaTeX parse error: Expected '}', got 'EOF' at end of input: … if ((strpos(_SERVER[‘HTTP_ACCEPT’], ‘vnd.wap.wml’) !== false) && (strpos( S E R V E R [ ′ H T T P A C C E P T ′ ] , ′ t e x t m l ′ ) = = = f a l s e ∣ ∣ ( s t r p o s ( _SERVER['HTTP_ACCEPT'], 'textml') === false || (strpos( SERVER[′HTTPACCEPT′],′textml′)===false∣∣(strpos(_SERVER[‘HTTP_ACCEPT’], ‘vnd.wap.wml’) < strpos($_SERVER[‘HTTP_ACCEPT’], ‘textml’))))
{
return true;
}
}
return false;
}