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

[eluser]thekrow[/eluser]
Hello,

I'd like to know why I'm getting an error when I call "load_file()" located in my index function in my one of my controllers, something like this:

function index()
{
$this->load_files();
}

function load_files()
{
require_once('top_file.php');

$this->smarty->assign('top',$top);
}

The error I'm getting is "Undefined variable: top". The 'top' variable as you can see from the code is stored in "top_file.php". I don't understand why the variable is undefined. If I call "require_once()" directly in index() then my program works fine. The problem is when I use require_once in a different function different from index().

Any help/suggestions will mean a lot to me, thank you.


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