A member variable is a variable which belongs to a class. In this case it belongs to the class with the
getLanguages/getLanguage methods (function). You declare it at the top of the class (see code example below) and then can assign values to it using the [inline]$this->variable_name[/i] syntax. We'll declare the variable as
public because we need access to it from outside the class.
PHP Code:
class Lang {
public $phrases = array();
// I'm just giving you the general idea, don't just copy/paste!
public getLanguage(...) {
include(...);
$this->phrases = $lang;
}
}
You can then access that variable from the instance of the class.
PHP Code:
$pLanguage = new Lang();
$pLanguage->getLanguage('french');
echo $pLanguage->phrases['first_page'];
// Alternatively, if you want to keep the $lang['...'] style
$pLanguage = new Lang();
$pLanguage->getLanguage('french');
$lang = &$pLanguage->phrases;
echo $lang['first_page'];
Finally, with reference to my 'hackish' comment. I really, really don't like assigning values to the
$GLOBALS array and as a result assigning global variables (
$GLOBALS['myvar'] is the same as [inline]$myvar[/i] in the global scope). It's like using
global $myvar in PHP4 functions, urgh.