 <p>The problem is that you are loading the lang file from inside a function, which means that <code>$lang</code> does not get placed into the global scope but rather the local function scope.</p> <p><strong>Minimum required change to make it work (but not a good idea)</strong></p> <p>Assuming you <em>want</em> <code>$lang</code> to be placed inside the global scope, you could do so explicitly:</p> <pre><code>public function lang($file, $language){ require 'languages/'.$language.'/'. $file . '.php'; $GLOBALS['lang'] = $lang; // "export" to global scope } </code></pre> <p><strong>A much better idea</strong></p> <p>There are several things that can be improved:</p> <ol> <li>The function above writes the contents of the global variable <code>$lang</code> "behind the caller's back" -- that's not good design, and it makes the code harder to maintain</li> <li>As it stands, it loads the language file from scratch every time you call it</li> </ol> <p>You can kill both birds with one stone by storing the language file contents inside a <code>static</code> local variable and returning it from the function: there is no more writing to the global scope, and the variable keeps its contents so you don't have to reload the language file every time. It would look like this:</p> <pre><code>public function lang($file, $language){ static $cache = array(); if (empty($cache[$language][$file])) { // load language files on demand require 'languages/'.$language.'/'. $file . '.php'; $cache[$language][$file] = $lang; } return $lang; // return requested data, which is now definitely cached } </code></pre> <p>And to use it, you would do:</p> <pre><code>$lang = $this-&gt;lang('global', 'en'); </code></pre> <p>Dumping raw variables into the global scope like this is not always the best idea, but depending on the circumstances (small projects) it might be OK.</p>