Help with Default Date Value in PHP function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hoopz
Forum Newbie
Posts: 2
Joined: Sun Jul 31, 2005 4:26 am

Help with Default Date Value in PHP function

Post 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
sheila
Forum Commoner
Posts: 98
Joined: Mon Sep 05, 2005 9:52 pm
Location: Texas

Post by sheila »

How about this for a work around?

Code: Select all

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

}
hoopz
Forum Newbie
Posts: 2
Joined: Sun Jul 31, 2005 4:26 am

Post by hoopz »

oh! hey! that's great. Thanks so much!

Hoopz
Post Reply