php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #31441 passing by reference in variable-length argument lists
Submitted: 2005-01-07 13:44 UTC Modified: 2014-11-01 23:23 UTC
Votes:5
Avg. Score:4.0 ± 0.9
Reproduced:5 of 5 (100.0%)
Same Version:1 (20.0%)
Same OS:2 (40.0%)
From: hagen at cookfast dot net Assigned: requinix (profile)
Status: Closed Package: *General Issues
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: hagen at cookfast dot net
New email:
PHP Version: OS:

 

 [2005-01-07 13:44 UTC] hagen at cookfast dot net
Description:
------------
In my opinion it should be possible to pass by reference when using variable-length argument lists. I know that there are quite a lot of workarounds for this but none of them is really appealing to me. For the sake of orthogonality it should be possible to use user defined functions with variable-length argument lists in the same way as without.
See my listing for a possible use of this.
Do not tell me these variables could be packed into an array.
This feature request does not contain scope inheritance as requested in bug #11472.

Reproduce code:
---------------
// We've got some strings from user input
// named $a, $b and $c
// and want them to be escaped and converted somehow

// with passing by reference this could look like
my_conversion($a,$b,$c);

// possible workaround now:
list($a,$b,$c) = my_conversion($a,$b,$c)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-11-01 23:23 UTC] requinix@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: requinix
 [2014-11-01 23:23 UTC] requinix@php.net
just pack the variables into an array lol

Kidding. Variadics in PHP 5.6 supports passing by-reference.
https://wiki.php.net/rfc/variadics#by-reference_capture
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 08 20:01:28 2024 UTC