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
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: 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: Wed May 15 07:01:32 2024 UTC