|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #17076 Omitting defaulted arguments
Submitted: 2002-05-07 12:51 UTC Modified: 2002-05-07 14:30 UTC
Avg. Score:4.5 ± 0.8
Reproduced:6 of 6 (100.0%)
Same Version:1 (16.7%)
Same OS:2 (33.3%)
From: csaba at alum dot mit dot edu Assigned:
Status: Suspended Package: Feature/Change Request
PHP Version: 4.2.0 OS: All
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.
Block user comment
Status: Assign to:
Bug Type:
From: csaba at alum dot mit dot edu
New email:
PHP Version: OS:


 [2002-05-07 12:51 UTC] csaba at alum dot mit dot edu
This is an enhancement request for about the only thing that I can think of offhand that exists in VB that I really miss in PHP:

I would like to be able to declare, say,
function myFunc ($arg0, $arg1="One", $arg2="Two", $arg3=3)

and call it thusly:  myFunc ("Hi", , "Mom")

In other words, if I omit an argument to a function where the value is defaulted (in our example we are talking about position 1, in addition to position 3), PHP should take the default value instead of complaining.  Of course I can always figure out what the default value was in the first place by checking the function definition and plunking it into my call explicitely, but isn't this the same convenience that the current method tries to offer us?  This is just a proposal to extend it.

Motivation: This comes up frequently for me because I have several functions which take 3 parameters which are normally defaulted, and usually at most one varies.  So unless it's the first of the three, I have to fill in extra values that distract from what's going on.

   Thanks for considering this,
       Csaba Gabor


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-07 14:30 UTC]
This is not one of the easily done changes to the engine and to the language. This has come up before a few times in the past and I suggest participating discussion about this on either php-dev or the engine2 mailing list. Suspending until a final consensus is reach (if not already and I just missed it).
 [2008-01-18 20:43 UTC] pete at teamlupus dot hu

is there any follow-up on this subject? It's a really must-have IMHO, just very unfortunate that it needs a major change to the engine :( Is it an issue with the new Zend engine in PHP5, too?
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Sep 27 02:03:36 2021 UTC