title: Codeigniter cannot redeclare class
body: <p><strong>Not: Its work just one time in loop. Its return this error for other time.</strong> </p>
  
  <p>I have a usermodel.php in models. When i use it like </p>
  
  <pre><code>$this-&gt;load-&gt;model("Usermodel");
  $user = $this-&gt;Usermodel-&gt;quer(1);
  </code></pre>
  
  <p>it throw "Message: Undefined property: CI_Loader::$Usermodel" </p>
  
  <p>When i use </p>
  
  <pre><code>$this-&gt;load-&gt;model("Usermodel");
  $user = new Usermodel();
  </code></pre>
  
  <p>it throw "Message: Cannot redeclare class Users"</p>
  
  <p>user class has construct and desturct functions. I call it in Usermodel.php file. And usermodel has construct and destruct functions.</p>
  
  <pre><code>&lt;?php 
  class User {
          public function __construct(){
          parent::__construct();
  }
  private $id;
  private $email;
  private $name;
  private $profilPic;
  private $topPic;
  private $gender;
  private $birthday;
  
  private function setid($id){
      $this-&gt;id = $id;
  }
  private function getid(){
      return $this-&gt;id;
  }
  private function setemail($email){
      $this-&gt;email = $email;
  }
  private function getemail(){
      return $this-&gt;email;
  }
  private function setname($name){
      $this-&gt;name = $name;
  }
  private function getname(){
      return $this-&gt;name;
  }
  private function setprofilPic($profilPic){
      $this-&gt;profilPic = $profilPic;
  }
  private function getprofilPic(){
      return $this-&gt;profilPic;
  }
  private function settopPic($topPic){
      $this-&gt;topPic = $topPic;
  }
  private function gettopPic(){
      return $this-&gt;topPic;
  }
  private function setgender($gender){
      $this-&gt;gender = $gender;
  }
  private function getgender(){
      return $this-&gt;gender;
  }
  private function setbirthday($birthday){
      $this-&gt;birthday= $birthday;
  }
  private function getbirhday(){
      return $this-&gt;birthday;
  }
  
  public function __set($name, $value){
      $functionname = 'set'.$name;
      return $this-&gt;$functionname($value);
  }
  public function __get($name){
      $functionname = 'get'.$name;
      return $this-&gt;$functionname();
  }
  
  public function __destruct(){}
  }
  
  ?&gt;
  </code></pre>
  
  <p>This is usermodel</p>
  
  <pre><code>&lt;?php 
  defined('BASEPATH') OR exit('No direct script access allowed');
  class Usermodel extends CI_Model {
      public function __construct(){
          parent::__construct();
          $this-&gt;load-&gt;view("Users.php");
          $this-&gt;load-&gt;model("Dbmodel");
      }
      public function quer($id){
          $uqcont = array("id" =&gt; $id);
          $uiqcont = array("userID", $id);
          $uq = $this-&gt;Dbmodel-&gt;control("user", $uqcont);
          $uiq = $this-&gt;Dbmodel-&gt;control("userinfo", $uiqcont, $limit=1, 'userID');
          $user = new Users();
          if($uq-&gt;num_rows()==1){
              $uq = $uq-&gt;result();
              $user-&gt;id=$id;
              $user-&gt;name=$uq[0]-&gt;name;
              $user-&gt;email=$uq[0]-&gt;email;
              $user-&gt;profilPic="girlprofil.png";
              $user-&gt;topPic="arka.jpg";
          }
          if($uiq-&gt;num_rows()==1){
              $uiq=$uiq-&gt;result();
              if($uiq[0]-&gt;profilPic){
                  $user-&gt;profilPic = $uiq[0]-&gt;profilPic;
              }
              if($uiq[0]-&gt;topPic){
                  $user-&gt;topPic = $uiq[0]-&gt;topPic;
              }
          }
          return $user;
      }
  
      public function __destruct(){}
  
  }
  ?&gt;
  </code></pre>
  
  <p>This is a part of my view.php</p>
  
  <pre><code>foreach($query-&gt;result() as $row){
       $cont = array("id" =&gt; $row-&gt;userID);
       $query = $this-&gt;Dbmodel-&gt;control("user", $cont);
       $this-&gt;load-&gt;model("Usermodel");
       $user = new Usermodel();
       $user = $user-&gt;quer($row-&gt;userID);
       $date = new datetime($row-&gt;date);
       $date = $date-&gt;format("d.m.Y H:i:s");
  
       //$query = $query-&gt;result();
       //foreach($query as $qur){
       echo '$user-&gt;name.'&lt;br&gt;'.$row-&gt;comment;
  
       //}
       //unset($user);
  }
  </code></pre>
  
  <p>Please look to my error and help me to solve it. </p>
  
  <p><a href="https://i.stack.imgur.com/LMKGs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LMKGs.png" alt="This is my error"></a></p>
  
  <p><a href="https://i.stack.imgur.com/usUif.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/usUif.png" alt="Error image"></a></p>