Dimitri Onfire
Dimitri Onfire

Reputation: 23

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.

Upvotes: 0

Views: 118

Answers (2)

Hugo Mota
Hugo Mota

Reputation: 11547

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.

Upvotes: 1

Blender
Blender

Reputation: 298136

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?

Upvotes: 1

Related Questions