I’m really confused because i have the following case:
Class Game extends CI_Model{
$this->load->model('user');
public $user = 'foo';
$var = $this->user; // Model Or Local Variable?
}
How can i tell which one should it use, the Model User or the local public variable $user?
$this->useris not the same as$userThe model you loaded with
$this->load->model('user');is only accessable through the$thisvariable. Furthermore, you should only acccess it through the variable scope which the model already is placed in (makes more sense, if you will).Local method variables, as you’re trying to do with
$var = $this->user;, is only accessable through a method.So, correcting your code, it would look something like this: