title: model return value in codeigniter
body: <p>I store the return value from my model in a <code>$result</code>:</p>
  
  <pre><code>$result = $this-&gt;absensi_m-&gt;absensi();
  </code></pre>
  
  <p>Based on what i return in the <code>absensi()</code> function, the value of <code>$result</code> will be one of these :</p>
  
  <ul>
  <li>FALSE</li>
  <li>'sudah absen' (a String)</li>
  <li>1 (indicating success)</li>
  </ul>
  
  <p>Then i try to see the <code>$result</code> value using <code>echo $result;</code> and it returns <strong>1</strong></p>
  
  <p>But, i get a strange error when i try to use <code>$result</code> for some validations :</p>
  
  <pre><code>        if($result == FALSE)
              $data['result'] = 'Anda Belum Terdaftar, Silahkan Daftar Dahulu :D';
          else if($result == 'sudah absen')
              $data['result'] = 'Anda Sudah Absen Hari Ini :D';
          else 
              $data['result'] = 'Selamat Datang, '.$this-&gt;input-&gt;post('txtNama').'! ^^';
  </code></pre>
  
  <p>Although the value of  <code>$result</code> is <strong>1</strong>, the second if (<code>$result == 'sudah absen'</code>) always return <strong>TRUE</strong>. </p>
  
  <p>Whats going on here?Thanks :D</p>
  
  <p>This is the <code>absensi()</code> function in my model : </p>
  
  <pre><code>public function absensi() {
          $nama = $this-&gt;input-&gt;post('txtNama');
          $tanggal = date('Y-m-d', now());
  
          $this-&gt;db-&gt;select('umat_id');
          $terdaftar = $this-&gt;db-&gt;get_where('msumat', array('nama' =&gt; $nama));
  
          $row = $terdaftar-&gt;row_array();
          $sudah_absen = $this-&gt;db-&gt;get_where('msabsensi', array('umat_id' =&gt; $row['umat_id'], 'absensi_tanggal' =&gt; $tanggal));
  
          if($terdaftar-&gt;num_rows() != 0 &amp;&amp; $sudah_absen-&gt;num_rows() == 0)
          {
              $data_umat = array(
              'umat_id' =&gt; $row['umat_id'],
              'status' =&gt; 'H',
              'absensi_tanggal' =&gt; date('Y-m-d')
              );
  
              return $this-&gt;db-&gt;insert('msabsensi', $data_umat);
          }
          else if($sudah_absen-&gt;num_rows() != 0)
              return 'sudah absen';
          else
              return FALSE;
      }
  </code></pre>
  
  <p><strong>ANSWER :</strong>
  I will answer here because you may be confused with a lot of comments/conversation.</p>
  
  <p>I realized whats going on by using <code>var_dump()</code> and <code>echo</code> (<strong>Thanks to both answers below</strong>):</p>
  
  <pre><code>$result = $this-&gt;absensi_m-&gt;absensi();
  var_dump($result);
  echo $result;
  </code></pre>
  
  <p>The <code>var_dump()</code> returns <code>bool(true)</code> while the <code>echo</code> returns 1. This means that this problem is occured because i think the <code>$result</code> value is 1(integer), while the real value is TRUE(bool).</p>
  
  <p>The conclusion is : echoing a variable with a TRUE(bool) value will result 1(integer), so use the <code>var_dump()</code> instead of <code>echo</code>.</p>