vendredi 15 mai 2015

php $variables don't work outside IF statement

else {
    if ($_COOKIE['HotspotLanguage'] == 'ENG') { $url_lang_code = '?lang=eng'; header('Location: '.$url_captive_portal.$url_lang_code.'');
    }elseif ($_COOKIE['HotspotLanguage'] == 'ALB') { $url_lang_code = '?lang=alb'; header('Location: '.$url_captive_portal.$url_lang_code.'');  
    }elseif ($_COOKIE['HotspotLanguage'] == 'MKD') { $url_lang_code = '?lang=mkd'; header('Location: '.$url_captive_portal.$url_lang_code.'');
    }
}

As you can see from the code above, I have defined a veriable $url_lang_code; however, my variable doesn't work outside the if statement.

The URL gets rewritten, that works. But if I use $url_lang_code, somewhere outside the if statement, it doesn't work...

Am I doing something wrong?

Aucun commentaire:

Enregistrer un commentaire