Oct 11
15
PHP Language Detection
Leave a comment »
There is a very simple method to detect what language the users web browser is using.
The following code:
//session variable ensures it's available
//throughout current session
$_SESSION['lang'] = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
echo $_SESSION['lang'];
Will give you the correct two letter ISO code for the language the browser is using.