Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2011
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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.

  • #2
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,285
    Thanks
    4
    Thanked 201 Times in 198 Posts
    PHP Code:
    function funcName($today) {
        if (empty(
    $today)) {$today date('Y-m-d');}

    Dave .... HostMonster for all of your hosting needs


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •