【问题标题】:How do you append for example ?lang=en_US to the url based on a cookie containing country code?例如,如何根据包含国家代码的 cookie 将 ?lang=en_US 附加到 url?
【发布时间】:2011-03-18 04:27:22
【问题描述】:

我有一个这样的代码,可以提取保存在 cookie 中的国家代码。

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

                    $language = "eng";

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

现在我需要从$supported_locales = array('en_US', 'no_NO'); 追加语言

并将其附加到 url,使其看起来像这样 http://localhost/site/test.php?lang=no_NO

我该怎么做?

【问题讨论】:

    标签: php url url-rewriting cookies append


    【解决方案1】:
    header('Location: http://localhost/site/test.php?lang='.$language);  
    

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

    【讨论】:

      猜你喜欢
      • 2016-11-19
      • 1970-01-01
      • 2021-01-20
      • 1970-01-01
      • 2013-10-19
      • 2021-08-02
      • 1970-01-01
      • 2016-08-14
      • 1970-01-01
      相关资源
      最近更新 更多