php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27887 func_get_args() can't be used as 2nd parameter for functions
Submitted: 2004-04-06 10:41 UTC Modified: 2005-06-16 09:04 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: dams@php.net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5CVS, 4CVS (2004-04-06) OS: *
Private report: No CVE-ID: None
 [2004-04-06 10:41 UTC] dams@php.net
Description:
------------
when passing func_get_args() as second parameter of a 
function, it complains.

foo('foo', func_get_args());
Fatal error: func_get_args(): Can't be used as a 
function parameter in /Users/iboom/Desktop/Journaux/
2004.04/fonctions/arg_defaut.php on line 23


foo(func_get_args(), 'foo');
is OK tough.

So, it won't work with
print join(',',func_get_args());
array_map('foo',func_get_args());


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-02 16:19 UTC] hkh at netnords dot dk
Reproduce code:

function a()
{
	print func_num_args().'<br />';
}

function b()
{
	$dd = 123;
	a(func_get_args());
	a(func_get_args(), $dd);
	a($dd, func_get_args());
}

b('Hello World');

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

1
2
2

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

1
2

Fatal error: func_get_args(): Can't be used as a function parameter in .........


------------------------------------------
Comment:

I tested the code with same result on 4.3.10-1.dotdeb.0 and 5.0.3-1.dotdeb.0.

I think all the lines should fails on none of them.

Can't see anything in the documentation about this.
 [2005-06-16 01:34 UTC] tony2001@php.net
Damien, the docs say: "This function cannot be used directly as a function parameter. Instead, its result may be assigned to a variable, which can then be passed to the function.", so don't use it as a parameter.
 [2005-06-16 09:04 UTC] derick@php.net
So there is no bug, and the docs already describe it -> bogus.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 12:01:31 2024 UTC