how to create code to switch english to french and french to english on the same link in php
Here is a link to switch text in english on my source code:
<a href="index.开发者_如何转开发php?lang=en">Not french</a>
It works. But on the english text page, link still shows up "Not french". I want it display "Not english" when text is english.
Maybe some logic would be helpful?
<a href="index.php?lang=en">Not <?php if (isset($_GET['lang']) && $_GET['lang'] == 'en') {echo "French";} else {echo "English";} ?></a>
Your question is quite vague, so could you please explain what your problem is? Maybe some more code to place it into context?
if(isset($_GET['lang']) and $_GET['lang']=='en')
echo '<a href="index.php">French</a>'
else
echo '<a href="index.php?lang=en">Not french</a>'
Although I would recommend that you store lang
in session to clean up you url's.
精彩评论