PHP Browser language detection

This is how….

<?php
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
switch ($lang){
    case "pt":
        echo "Browser lang PT!";
        break;
    case "it":
        echo "Browser IT";
        break;
    case "en":
        echo "Browser lang EN";
        break;        
    default:
        echo "Browser lang EN - Setting Default";
        break;
}
?>

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*