I'm working on a webpage with language detection, and I have the following script so far (it's simple), so how could I improve it? I. I still haven't done the user detection, so it's not available to find the user language (yet), but this will be easily implemented. ThoughtThough I'm not asking for that, I'm asking for other ways to improve this code. So far as I've tested it, it's bug-free, but I want it to be bulletproof by experts like you. How can I improve it? (oror expand it?)
Code:
//LANGUAGES
//Language detection
if ( !empty($_POST['lang']) )
{
$Lang = $_POST['lang'];
$_SESSION['lang']= $_POST['lang'];
}
else
{
if ( !empty ($_SESSION['lang']))
$Lang = $_SESSION['lang'];
else
$Lang = substr ($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
}
//After this, $Lang will have the webpage preference
sorry for my English and thank you for reading this!