remember language
Posted: Wed Nov 12, 2008 3:34 pm
I have script (below).
i have file index.php which contains this script. then I have folder language which contains files en.php and ru.php. Both the files also contains the script.
Problem is that in such situation script does not work. If en.php and ru.php are blank or contains other code, script works.
What i need to do to get to work the script?
And other problem that Opera does not remember cookie.... FF and IE remember....
What I have to do?
<?php>
$languages = array('en' => 'English',
'ru' => 'Russian');
if (isset($_GET['lang'])) {
$lang = $_GET['lang'];
setcookie('lang', $lang, time()+(3600*24*365));
header("Location: index.php");
}else if (isset($_COOKIE['lang'])) {
$lang = $_COOKIE['lang'];
} else {
$lang = 'en';
}
if (!(in_array($lang, array_keys($languages)))) {
die("ERROR: Bad Language String Provided!");
}
include "language/{$lang}.php";
php?>
<a href="?lang=lv">Russian</a>
<a href="?lang=en">English</a>
i have file index.php which contains this script. then I have folder language which contains files en.php and ru.php. Both the files also contains the script.
Problem is that in such situation script does not work. If en.php and ru.php are blank or contains other code, script works.
What i need to do to get to work the script?
And other problem that Opera does not remember cookie.... FF and IE remember....
What I have to do?
<?php>
$languages = array('en' => 'English',
'ru' => 'Russian');
if (isset($_GET['lang'])) {
$lang = $_GET['lang'];
setcookie('lang', $lang, time()+(3600*24*365));
header("Location: index.php");
}else if (isset($_COOKIE['lang'])) {
$lang = $_COOKIE['lang'];
} else {
$lang = 'en';
}
if (!(in_array($lang, array_keys($languages)))) {
die("ERROR: Bad Language String Provided!");
}
include "language/{$lang}.php";
php?>
<a href="?lang=lv">Russian</a>
<a href="?lang=en">English</a>