Search code examples
javascriptphphtmlgettext

How to give parameter lang to another url


I use GetText library to have a multilingual website. It works great on my first page with this url http://localhost:8080/index.php?lang=en_US

But inside my page, I have link to another page. I'd like to keep lang=en_US to send to the second page to have this dynamically according to the selected language:

<a href="contact.php?lang=en_US">text here</a>

I don't know how to do it, if I have to create the url with appending string by getting parameter the first time and concatenate it? or session ?


Solution

  • One solution would be to change your links to something like this:

    <a href="contact.php?lang=<?=$_GET['lang']?>">text here</a>