$GLOBALS['_LANG'] = array( 'af'
, 'ar'
, 'en'
。。。
, 'zh'
);
function detectLanguage()
{ $_AL = strtolower($GLOBALS['HTTP_ACCEPT_LANGUAGE']);
$_UA = strtolower($GLOBALS['HTTP_USER_AGENT']);
foreach($GLOBALS['_LANG'] as $K) // Try to detect Primary language if several languages are accepted.
{ if(strpos($_AL, $K)===0)
{ return $K;
};
};
foreach($GLOBALS['_LANG'] as $K) // Try to detect any language if not yet detected.
{ if(strpos($_AL, $K)!==false)
{ return $K;
};
};
foreach($GLOBALS['_LANG'] as $K)
{ if(preg_match("/[[( ]{$K}[;,_-)]/",$_UA))
{ return $K;
};
};
}
, 'ar'
, 'en'
。。。
, 'zh'
);
function detectLanguage()
{ $_AL = strtolower($GLOBALS['HTTP_ACCEPT_LANGUAGE']);
$_UA = strtolower($GLOBALS['HTTP_USER_AGENT']);
foreach($GLOBALS['_LANG'] as $K) // Try to detect Primary language if several languages are accepted.
{ if(strpos($_AL, $K)===0)
{ return $K;
};
};
foreach($GLOBALS['_LANG'] as $K) // Try to detect any language if not yet detected.
{ if(strpos($_AL, $K)!==false)
{ return $K;
};
};
foreach($GLOBALS['_LANG'] as $K)
{ if(preg_match("/[[( ]{$K}[;,_-)]/",$_UA))
{ return $K;
};
};
}