Skip to content

Instantly share code, notes, and snippets.

@fethica
Created December 13, 2013 20:24
Show Gist options
  • Save fethica/7950768 to your computer and use it in GitHub Desktop.
Save fethica/7950768 to your computer and use it in GitHub Desktop.
Detect Browser Language in PHP
<?php
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
switch ($lang){
case "fr":
//echo "PAGE FR";
include("index_fr.php");//include check session FR
break;
case "it":
//echo "PAGE IT";
include("index_it.php");
break;
case "en":
//echo "PAGE EN";
include("index_en.php");
break;
default:
//echo "PAGE EN - Setting Default";
include("index_en.php");//include EN in all other cases of different lang detection
break;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment