Monday, October 4, 2010

PHP Variable Function Names

I always thought I'd never use this functionality of PHP due to getting lost in someone elses code trying to understand what they where doing with variable function names, but now it seems like I found a use for this:

   $this->$function();          

Basically I'm calling a function to generate a report and have an array of about 15 function names so I know which function to call for which report:



$this->report_list[2] = array(
        "report_name"     => "Agent Comm per Product Group",
        "report_function" => "agent_comm_per_product_group",
        "report_export_csv" => true,
        "report_select_dates" => false,
        "report_select_agent" => false
        );
      


Ref: http://php.net/manual/en/functions.variable-functions.php

No comments:

Followers