title: codeigniter declaring a class in to one variable
body: <p>i am trying to use <code>$admin-&gt;function()</code> instead <code>$this-&gt;admin_model-&gt;function()</code> 
  when i tried to declare a <code>variable</code> <code>$admin=new Admin_model;</code> in <code>constructor</code> and use it in other functions it gives error.. 
  my code is given below, i don't know much about <code>OOP</code> concept, somebody please help.</p>
  
  <pre><code>class Admin extends CI_Controller {
      var $admin;
      function __construct() {
          parent::__construct();
          $this-&gt;load-&gt;model('admin_model');
          $admin=new Admin_model;
      }
      public function index($value='')
      {
          if(!$admin-&gt;is_admin_logged_in()){
              redirect('admin/login?r='.urlencode(current_url()));
          }
          $data['loggedin']=TRUE;
          $data['account']=$this-&gt;session-&gt;all_userdata();
          $this-&gt;load-&gt;view('pages/admin-home',isset($data)?$data:NULL);
  
      }
  }
  </code></pre>
  
  <p>presently i am using this method</p>
  
  <p><code>public function login()// this function belongs to the same controller mentioned above
      {
          $r=isset($_GET['r'])?urldecode($_GET['r']):'admin';
          $admin=new Admin_model;
          if($admin-&gt;is_admin_logged_in()) redirect($r);
         }</code></p>
  
  <p>i don't want declare <code>$admin=new Admin_model;</code> in every single function and want to make the code look good and clean, so don't like to use <code>$this-&gt;admin</code> or <code>$this-&gt;admin_model</code> either.</p>