I hit a strange problem with PHP and its require_once
language construct.
I require file called EN-en.php
. It contains the English language for my website, I wrote it like this:
....
$lang['header']['loginbox']['menu'][1] = "contacts" ;
$lang['header']['loginbox']['menu'][2] = "settings" ;
....
Then I user this code to include my file in the whole site
require_once $langFile ;
Very easy I think, $langFile is = "/var/www/webstite/langs/EN-en.php"
. But here's come the strange part.
When I use
echo $lang['header']['loginbox']['menu'][1];
It prints something like "Gontacts" ... I can't understand why, and it's not the only case.. Please someone can help me with this issue?.
You are probably overwriting your own values in the array.
See this simple example:
$test = "some text";
$test['menu'] = 'extra';
var_dump($test);
// produces: string(9) "eome text"
// the first character - $test[0] - gets overwritten