php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #23439 Allow default values to be passed for functions
Submitted: 2003-05-01 09:38 UTC Modified: 2003-05-01 09:49 UTC
From: steveh at brendata dot co dot uk Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 4.3.1 OS: linux 2.4.20
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: steveh at brendata dot co dot uk
New email:
PHP Version: OS:

 

 [2003-05-01 09:38 UTC] steveh at brendata dot co dot uk
It would be useful to be able to omit function arguments and have the function still use the defaults even though some to the right were passed:

e.g.

function fred ($a,$b=1,$c=2,$d=3)
{
echo "a=$a,b=$b,c=$c,d=$d";
}


fred(-1);
fred(-1,,4,5);


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-01 09:45 UTC] derick@php.net
This was submitted before and respectfully declined. If you want to use something like this, you can either use an array based approach or use func_get_args().

Derick
 [2003-05-01 09:49 UTC] steveh at brendata dot co dot uk
Although your suggestion is appropriate for new code upgrading old libraries and then all the code that calls them makes it impractible for updates to existing code?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 21:01:33 2024 UTC