title: CodeIgniter Dynamic Method Calls
body: <p>I have a database with some "filters"; i.e. method calls and want to be able to call them dynamically dependent on what the user has input.    </p>
  
  <p>Code Igniter does not seem to like this however, any ideas?
  It outputs:
  In GetEmailCountfilter_male_count():</p>
  
  <pre><code>&lt;h4&gt;A PHP Error was encountered&lt;/h4&gt;
  
  &lt;p&gt;Severity: Notice&lt;/p&gt;
  &lt;p&gt;Message:  Undefined property: Targeted_Email::$filter_male_count()&lt;/p&gt;
  &lt;p&gt;Filename: core/Model.php&lt;/p&gt;
  &lt;p&gt;Line Number: 51&lt;/p&gt;
  
  {"emailCount":null}
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code> public function getEmailCount($filter){
        echo 'In GetEmailCount';
        $result = array();
        $query = $this-&gt;db-&gt;get('base_targeted_email_filters');
  
  
        foreach ($query-&gt;result() as $row){
             if($filter == $row-&gt;name){
  
                  $test = $row-&gt;filterCountFunction . "()";
                       echo $test;
                  $result['emailCount'] = $this-&gt;{$test};
             }
  
    return $result
    }
  </code></pre>