I am doing a languages page for my website, placing all texts in variables such as:
if($language=='en') {
lang[1]="Welcome, ".$user."!";
lang[2]="You have earned ".$pts." pts yesterday";
}
elseif($language=='fr') {
lang[1]="Bienvenue, ".$user."!";
lang[2]="Vous avez remporté ".$pts." pts hier";
}
I include this at the top of each page. However, the problem is that in many pages, some of the variables inside the $lang[X] variables (such as $user or $pts for instance) are only declared a few lines before their echo line or they even change a couple of times within a same page, so when the language vars are loaded via an include, they take the value of $user or $pts at that moment and not at the moment of their echo.
Is there a way to use the technique in such a way that the vars inside the $lang[X] are taken at the moment of their echo and not at the moment of their include()?