[eluser]Fielder[/eluser]
I have a variable say $var that is used throughout the entire controller. How do I define it at the beginning of the controller so I can call it anywhere in any function in the controller?
Is this correct?
Code:
<?php
class ContractStore_Form extends Controller
{
function ContractStore_Form()
{
parent::Controller();
$this->load->library('DX_Auth');
$this->load->library('RTUI_App');
$this->load->library('RTUI_Form_Elements');
$this->load->library('XajaxGrid');
$this->dx_auth->check_uri_permissions();
$this->load->model('Stores', 'store', TRUE);
$this->load->model('Contracts','contract', TRUE);
// Initialize
$this->_init();
}
function _init()
{
$this->var = 2;
}
function somefunc($storename_name)
{
$newvalue = $this->var + 4;
return $newvalue;
}
function anotherfunc($blah)
{
$newvalue = $this->var + 8;
return $newvalue;
}
.
.
.
And second to that, what if I wanted a function to perform a task to create a variable, but I didn't want to return it. I just wanted the results of the function to be available anywhere else in the controller.
Code:
function open()
{
$this->rowopen = "<tr><td>";
}
function close()
{
$this->rowclose = "</td></tr>";
}
function render()
{
$final = $this->rowopen . $this->rowclose;
}
I've tried just this and it doesn't work... I suspect something having to do with how the controller is setup.?
Thanks.