Welcome Guest, Not a member yet? Register   Sign In
variable as default parameter in function?
#1

[eluser]gscharlemann[/eluser]
I'm reading some data from a config file into an array. Is there a way to do this (I think php is barfing on my default parameter assignment)

Code:
class Tracker_model extends Model
{
    public $tables = array();

    public $schedule_sort_by = array();


    public function __construct()
    {
        parent::Model();
        $this->load->config('tracker');
        $this->tables = $this->config->item('tables');
        $this->schedule_sort_by = $this->config->item('schedule_sort_by');
    }

    public function get_user_schedule($user_id, $sort_by = $schedule_sort_by['scheduled_date'])
    {
          ...
    }
}
$schedule_sort_by['scheduled_date] is the "default" column heading I would like to sort by if it's not specified. I could hard code it, but the column name might change based on setup, that's why it's defined in the config file.

thanks!


Messages In This Thread
variable as default parameter in function? - by El Forum - 04-09-2010, 05:57 AM
variable as default parameter in function? - by El Forum - 04-09-2010, 06:12 AM
variable as default parameter in function? - by El Forum - 04-09-2010, 07:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB