Redirect with Browser Language

Started on the old forum in February 2010 · view the original in the archive · old links redirect here

No replies · 827 views · started 16 years ago · 1 min read

djdevil89 Senior · 287 posts #1
function getlang($enlang)
{
$lango = explode(",", $enlang);
$langos = str_replace("", "", $lango[0]);
$lang = "$langos[0]$langos[1]";
return $lang;
}
$mylang = getlang($_SERVER['HTTP_ACCEPT_LANGUAGE']);
echo "Your language is: $mylang<br />";
<?php
session_start();
$getlang = getlang($_SERVER['HTTP_ACCEPT_LANGUAGE']);
if ($getlang=="de")
{
$_SESSION['lang'] == "de";
echo "<b>You will be Redirected in 5 seconds to the site version which suits your Language</b><br />";
echo "<meta http-equiv=\"refresh\" content=\"5; url=german.html\">";
}
else
{
$_SESSION['lang'] == "en";
echo "<b>You will be Redirected in 5 seconds to the site version which suits your Language</b><br />";
echo "<meta http-equiv=\"refresh\" content=\"5; url=english.html\">";
}
?>
foreach ($_SERVER as $server => $value)
{
echo "$server is $value<br />";
}

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close