I use this simple module included in my header to let the user change language of the site
<div class="left first">
<a href="' . $_SERVER['REQUEST_URI'] . $linkParam . 'sv">
<img src="bilder/sv.png" alt="SV" />
</a>
</div>
<div class="left"><img src="bilder/eng.png" alt="ENG" /></div>
The language available for change is a link that send the lang param via a http request and thus set the language session. Before I always sended the user to index.php but I would like to make it possible to change language throughout the site and stay on the page.
Since some pages has http params which need to remain I use this solution to determine if the lang param should be ?lang=...or &lang=...
if($_SERVER['REQUEST_URI'] != $_SERVER['PHP_SELF']){
$linkParam = '&lang=';
}else{
$linkParam = '?lang=';
}
It is working fine with some test but will this consistently work to determine if the url already has ?param and set the lang-param?
Take a look at the http_build_query function, perhaps this will help you. You could do the following: