2010-07-19 41 views
0

我有這樣的代碼提取保存在cookie中的國家代碼。如何在基於包含國家/地區代碼的Cookie的基礎上添加例如?lang = en_US的示例?

 if (isset($_COOKIE['country'])) 
      { 
       $country = $_COOKIE['country']; 

        $language = "eng"; 

       if ($country == "NO"){    
        $language = "nor"; 
        }      
       } 
      else 
      { 
      $language = "eng"; 
      } 

現在我需要從$supported_locales = array('en_US', 'no_NO');

追加語言,所以它看起來像這樣http://localhost/site/test.php?lang=no_NO

我該怎麼做,它追加到URL?

回答

1
header('Location: http://localhost/site/test.php?lang='.$language); 

echo '<script>location.href="http://localhost/site/test.php?lang='.$language.'"</script>';