代码之家  ›  专栏  ›  技术社区  ›  ganjan

例如,如何根据包含国家代码的cookie将lang=en\u US附加到url?

  •  0
  • ganjan  · 技术社区  · 15 年前

            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

    我该怎么做?

    1 回复  |  直到 15 年前
        1
  •  1
  •   Luis Junior    15 年前
    header('Location: http://localhost/site/test.php?lang='.$language);  
    

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