My task seems to be failry simple, yet I am not sure how to approach it in a simple way. What i would like to accomplish is give user a choice in language english / french.
Is there a way to declare a global variable that the page can carry on ( remember ) without having to add language selection on every link such as this http://www.somepage.com/page.php?lang=en ?
any help would be great.
thank you.
HX
language select ... need some help
Moderator: General Moderators
http://us3.php.net/session
At the beginning of page.php, you could have a simple condition, stating that if $_GET['lang'] is set and has a valid value, alter the $_SESSION variable to whichever language the user is trying to view. Then when you output text, you could decide which language to output a bunch of ways - the easiest being:
At the beginning of page.php, you could have a simple condition, stating that if $_GET['lang'] is set and has a valid value, alter the $_SESSION variable to whichever language the user is trying to view. Then when you output text, you could decide which language to output a bunch of ways - the easiest being:
Code: Select all
if ( $_SESSION['lang'] == "en" )
echo "ENGLISH";
else if ( $_SESSION['lang'] == "fr" )
echo "FRENCH";
else if ( $_SESSION['lang'] == "sp" )
echo "SPANISH";