php.net |  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
Votes:6
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
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: 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-07 14:30 UTC] mfischer@php.net
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
Hi,

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 09:01:29 2024 UTC