title: How can I quickly check if GET and POST variables in CodeIgniter are both set and numeric?
body: <p>How can I quickly validate if a <code>GET</code> or <code>POST</code> variable in CodeIgniter is both set and numeric for use as error or status messages in views?</p>
  
  <p>It is very tedious to do something like this each time each time I want to check variables:</p>
  
  <pre><code>if ($this-&gt;input-&gt;get('error', True)) {
      if (is_numeric($this-&gt;input-&gt;get('error', True))) {
          $data['error'] = $this-&gt;input-&gt;get('error', True);
      }
  }
  </code></pre>