开发者

how to create code to switch english to french and french to english on the same link in php

开发者 https://www.devze.com 2023-03-25 15:37 出处:网络
Here is a link to switch text in english on my source code: <a href=\"index.开发者_如何转开发php?lang=en\">Not french</a>

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消