php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #37351 func_get_args() does not return variables by reference
Submitted: 2006-05-07 18:49 UTC Modified: 2008-02-16 17:58 UTC
Votes:4
Avg. Score:4.8 ± 0.4
Reproduced:4 of 4 (100.0%)
Same Version:4 (100.0%)
Same OS:2 (50.0%)
From: chris at starglade dot org Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.1.4 OS: Any
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: chris at starglade dot org
New email:
PHP Version: OS:

 

 [2006-05-07 18:49 UTC] chris at starglade dot org
Description:
------------
func_get_args() and func_get_arg() should return variables by reference.

Reproduce code:
---------------
<?php

$one = 'one';
$two = 'two';
$three = 'three';

function change_one_into_two_normal(&$var)
{
$var = 'two';
}

function change_one_into_two_using_get_args()
{
$args = func_get_args();
$args[0] = 'two';
}

change_one_into_two_normal($one);
echo $one;

$one = 'one';

change_one_into_two_using_get_args($one);
echo $one;

Expected result:
----------------
two
one

Actual result:
--------------
two
two

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-15 14:42 UTC] thomas at koch dot ro
is the same as
http://bugs.php.net/bug.php?id=6427
 [2008-02-16 17:58 UTC] johannes@php.net
By the time func_get_args() is being called the parameters were already passed to the function, it's too late for making them references. You might work-aroudn this limitation by wrapping references in an array or using objects.
 [2008-02-16 17:58 UTC] johannes@php.net
.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Aug 01 12:00:03 2025 UTC