Welcome Guest, Not a member yet? Register   Sign In
Calling 'require_once' from a controller
#7

[eluser]Pert[/eluser]
Ah, right, I can now see what's going on.

Your includes are included in your <strong>load_files</strong> method. Any local variables set in the method will be deleted once method has finished and are therefore not available.

Code:
function index()
{
    $this->load_files();
    echo $a; // $a is undefined
}

function load_files()
{
   // via include
   $a = 'a';
}

You can either attach your language elements to <b>$this</b> object in include file:

Code:
// before
$a = 'random language element';

// after
$this->a = 'random language element';

Or you can move includes in main method.


Messages In This Thread
Calling 'require_once' from a controller - by El Forum - 06-04-2013, 01:15 PM
Calling 'require_once' from a controller - by El Forum - 06-05-2013, 01:25 AM
Calling 'require_once' from a controller - by El Forum - 06-05-2013, 05:39 AM
Calling 'require_once' from a controller - by El Forum - 06-05-2013, 06:12 AM
Calling 'require_once' from a controller - by El Forum - 06-06-2013, 02:42 PM
Calling 'require_once' from a controller - by El Forum - 06-06-2013, 05:41 PM
Calling 'require_once' from a controller - by El Forum - 06-07-2013, 01:18 AM
Calling 'require_once' from a controller - by El Forum - 06-07-2013, 01:19 AM
Calling 'require_once' from a controller - by El Forum - 06-07-2013, 09:02 AM
Calling 'require_once' from a controller - by El Forum - 06-07-2013, 09:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB