Hello, I am new to PHP and I was wondering if somebody could help me. I am using PHP to echo a bit of pre-translated text. You click here and your text is now in French. You get the idea. My problem is that with my script all the text echoed becomes a link, which I don't want. What am I doing wrong? Thanks some advise. <html> <head> </head> <body> <a href="./test.php?language=english">english</a> <a href="./test.php?language=french">french</a> <?php $language = english; if ( $_GET['language'] == english ) { echo "this text is in english"; } else { echo "ce texte est en francais"; } ?> </body> </html> HTML:
The error probably comes from the browser you are using, but don't make such mistakes: $language = english. The correct is $language = 'english'.
Something like this would work fine <html> <head> </head> <body> <a href="./test.php?language=english">english</a> - <a href="./test.php?language=french">french</a> <?php (isset($_GET['language']))?$lang='english':$lang='french'; if($lang=='english') { echo 'this text is in english'; } else { echo 'ce texte est en francais'; } ?> </body> </html> PHP: