PHP4 including file during session

Posted by Matherw on Stack Overflow See other posts from Stack Overflow or by Matherw
Published on 2010-04-13T13:52:39Z Indexed on 2010/04/13 14:13 UTC
Read the original article Hit count: 652

Filed under:
|
|

I am trying to put second language on my webpage. I decided to use different files for different languages told apart by path - language/pl/projects.ln contains Polish text, language/en/projects.ln - English. Those extensions are just to tell language files from other, the content is simple php:

$lang["desc"]["fabrics"]["title"] = "MATERIALY";
$lang["desc"]["fabrics"]["short_text"] = "Jakis tam tekst na temat materialów";
$lang["desc"]["services"]["title"] = "USLUGI";
$lang["desc"]["services"]["short_text"] = "Jakis tam tekst na temat uslóg";

And then on the index page I use it like so:

session_start();  
if (isset($_SESSION["lang"])) {  
    $language = $_SESSION["lang"];  
} else {  
    $language = "pl";  
}  
include_once("language/$language/projects.ln");
print $lang["desc"]["fabrics"]["title"];

The problem is that if the session variable is not set everything works fine and array item content is displayed but once I change and set $_SESSION["lang"] nothing is displayed. I tested if the include itself works as it should by putting print "sth"; at the beginning of projects.ln file and that works all right both with $_SESSION["lang"] set and unset.

Please help.

© Stack Overflow or respective owner

Related posts about php4

Related posts about include