[PHP] Error with array and include
Hi, I'm having a strange problem when trying to show a array after its value was defined on a file that was included. Something like this: ?php $lang = 'pt_BR'; include('lang/'. $lang .'/login.php'); echo $lang['Username']; ? On the file lang/pt_BR/login.php i have this... ?php $lang['Username'] = 'Usuário'; ? But the result of the first script is 'S' (without quotes). If i change lang/pt_BR/login.php to ?php $lang['Username'] = 'Usuário'; echo $lang['Username']; ? I get 'Usuário' (without quotes again). Why does this happens? Thanks, Fernando. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Error with array and include
How can you use an array as string in the include statement and two lines lower as array? Think it echo's 'S' because it see's $lang as a string and not an array. On Tue, 05 Dec 2006 13:11:12 -0200, Fernando M. M. [EMAIL PROTECTED] wrote: Hi, I'm having a strange problem when trying to show a array after its value was defined on a file that was included. Something like this: ?php $lang = 'pt_BR'; include('lang/'. $lang .'/login.php'); echo $lang['Username']; ? On the file lang/pt_BR/login.php i have this... ?php $lang['Username'] = 'Usuário'; ? But the result of the first script is 'S' (without quotes). If i change lang/pt_BR/login.php to ?php $lang['Username'] = 'Usuário'; echo $lang['Username']; ? I get 'Usuário' (without quotes again). Why does this happens? Thanks, Fernando. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Error with array and include
T.Lensselink, Ok, problem solved. I didn't realized that i was using the same variable. Thanks for the help! T.Lensselink escreveu: How can you use an array as string in the include statement and two lines lower as array? Think it echo's 'S' because it see's $lang as a string and not an array. On Tue, 05 Dec 2006 13:11:12 -0200, Fernando M. M. [EMAIL PROTECTED] wrote: Hi, I'm having a strange problem when trying to show a array after its value was defined on a file that was included. Something like this: ?php $lang = 'pt_BR'; include('lang/'. $lang .'/login.php'); echo $lang['Username']; ? On the file lang/pt_BR/login.php i have this... ?php $lang['Username'] = 'Usuário'; ? But the result of the first script is 'S' (without quotes). If i change lang/pt_BR/login.php to ?php $lang['Username'] = 'Usuário'; echo $lang['Username']; ? I get 'Usuário' (without quotes again). Why does this happens? Thanks, Fernando. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Error with array and include
On Tue, December 5, 2006 9:11 am, Fernando M. M. wrote: Hi, I'm having a strange problem when trying to show a array after its value was defined on a file that was included. Something like this: ?php $lang = 'pt_BR'; include('lang/'. $lang .'/login.php'); echo $lang['Username']; You are using $lang for BOTH the language to include, and then again as an array for content within that language. Don't do that. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php