[eluser]Unknown[/eluser]
thanks but i am not sure that answer my question
here is some code to visualize what i am saying
Code:
class test extends CI_Controller {
var $ctrl_var=10;
public function index(){
echo $this->ctrl_var; //here display 10
$this->load->model('test_model');
echo $this->ctrl_var; //here display 10
}
}
class test_model extends CI_Model{
var $my_model_var="Halo";
function __construct(){
parent::__construct();
echo $this->ctrl_var; //here display 10
var_dump(isset($this->ctrl_var)); //here display bool(false) !!????
print_r(get_defined_vars()); //here display Array ( [this] => test_model Object ( [my_model_var] => Halo ) )
var_dump(isset($GLOBALS['CI']->ctrl_var)); // here display bool(true)
$this->ctrl_var = 20;
echo $this->ctrl_var; //here display 20
var_dump(isset($this->ctrl_var)); //here display bool(true)
print_r(get_defined_vars()); //here display Array ( [this] => test_model Object ( [my_model_var] => Halo [ctrl_var] => 20 ) )
}
}
if you meant that my ctrl_var inside the model is only a reference to the controller's variable , so i believe that modifying it in the model would also modify it in the controller.
and also i believe that isset an existing reference return true
???