Page 1 of 1

Help with Default Date Value in PHP function

Posted: Mon Jan 30, 2006 5:32 pm
by hoopz
I have the following:

Code: Select all

function which_day($day) {
}
and I wanted to assign $day a default value by doing the following:

Code: Select all

function which_day($day = date("d")) {
}
But it doesn't work. Am I just S.O.L.? or is there an alternate option?

Thanks for your time,
Hoopz

Posted: Mon Jan 30, 2006 5:38 pm
by sheila
How about this for a work around?

Code: Select all

function which_day($day = -1) {
    if ($day == -1) {
        $day = date("d");
    }

}

Posted: Mon Jan 30, 2006 5:43 pm
by hoopz
oh! hey! that's great. Thanks so much!

Hoopz