php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #41142 Default parameters for functions
Submitted: 2007-04-20 00:32 UTC Modified: 2007-04-20 05:32 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: flopin at webgarden dot cz Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 6CVS-2007-04-20 (snap) OS: any
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: flopin at webgarden dot cz
New email:
PHP Version: OS:

 

 [2007-04-20 00:32 UTC] flopin at webgarden dot cz
Description:
------------
It would be nice to find a way how to explicitly set a name of parameter passed to the function, which has default values for its parameters, so i could change only the values i need to change. It can be bypassed in several ways (arrays, classes etc.), but it allways results in bunches of code, which is not nessesary and makes the program less practical.
Bug #17076 suggests a possibility of omitting default parameters, but the solution still requires to keep order of parameters.

Reproduce code:
---------------
function x($a='AAA', $b='BBB') {
	print $a;
	print $b;
}

x($b='111'); //or any other suitable syntax

Expected result:
----------------
AAA111

Actual result:
--------------
111BBB

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-20 05:32 UTC] johannes@php.net
That was often discussed and isn't planned to be included into PHP. Please see Archives of the internals list for discussions about it.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 08:01:29 2024 UTC