Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 17th Feb 2012, 01:10 AM   #1
Call Center Services
 
jalicia18's Avatar
 
Join Date: 2010
Location: Philippines
Posts: 146
Thanks: 3
Thanked 9 Times in 9 Posts
Default
How do I set default value of function parameter as today's date?
Share on: 
fb share twitter share gplus share more share

How do I set default value of function parameter as today's date?

I tried:
function funcName($today=date('Y-m-d')) {do something}

Throws me this error:
Parse error: syntax error, unexpected '(', expecting ')'

Thanks.

jalicia18 is offline  
Unread 17th Feb 2012, 03:20 AM   #2
HyperActive Warrior
War Room Member
 
ussher's Avatar
 
Join Date: 2010
Location: Tokyo
Posts: 314
Thanks: 27
Thanked 43 Times in 42 Posts
Default
Re: How do I set default value of function parameter as today's date?
Share on: 
fb share twitter share gplus share more share

try:
function funcName($today=false) {
if(!$today){
$today = date('Y-m-d');
}

//do something

}

"Jamroom is a Profile Centric CMS system suitable as a development framework for building entire communities. Highly modular in concept. Suitable for enterprise level development teams or solo freelancers."
- jamroom.net
Download Jamroom free: Download
ussher is offline  
Unread 17th Feb 2012, 05:55 AM   #3
Warrior Member
 
Join Date: 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Re: How do I set default value of function parameter as today's date?
Share on: 
fb share twitter share gplus share more share

Just checking. Is this PHP?
guava is offline  
Unread 17th Feb 2012, 05:57 AM   #4
Warrior Member
 
Join Date: 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Re: How do I set default value of function parameter as today's date?
Share on: 
fb share twitter share gplus share more share

Is this PHP?
guava is offline  
Unread 17th Feb 2012, 06:16 AM   #5
VIP Warrior
War Room Member
 
Join Date: 2006
Location: , , USA.
Posts: 1,795
Thanks: 70
Thanked 287 Times in 259 Posts
Default
Re: How do I set default value of function parameter as today's date?
Share on: 
fb share twitter share gplus share more share

If this is for PHP
try:

define('TODAY', date('Y-m-d'));
function funcName($today=TODAY);
KirkMcD is offline  
Closed Thread


Bookmarks

Tags
date, default, function, parameter, set, today


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 05:25 PM.