/    Sign up×
Community /Pin to ProfileBookmark

problem in global variable definitions

Hello

I am trying to do the following:

define a global array called translation in a file called english.php:

[code=php]
<?php
$translation = Array();
$translation [‘hi’] = “hi”;
$translation [‘bye’] = “bye”;
?>
[/code]

a second file called LanguageManager.php has the following definition:

[code=php]
<?php
$languageData = Array();
$languageData[‘English’] = Array();
$languageData[‘English’][‘file’] = “english.php”;
?>
[/code]

This is the file that uses the code:

[code=php]
<?php
include_once(LanguageManager.php);

global $languageData;
include($languageData[$language][‘file’]);

gloabl $translation ;

print $translation [‘hi’];
?>
[/code]

I use the last segment of code whenever I want to display text to the screen.
The problem that sometimes I get a warning saying that ‘English’ was never defined as an index to $languageData.

What could cause this?

thanks

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@shimonApr 10.2004 — try removing all those 'global' calls - you don't need them. (You use 'global' within a function definition, to specify that you want to use the global variable called $whatever rather than create a new local variable called $whatever)

Also check your spelling in there...
×

Success!

Help @davidklonski spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...