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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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: Sat Jun 15 18:01:30 2024 UTC