#34120 [Asn->WFx]: func_get_arg() can be used function call parameter if used only once

From: Date: Fri, 21 Oct 2005 08:11:57 +0000
Subject: #34120 [Asn->WFx]: func_get_arg() can be used function call parameter if used only once
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-86847@lists.php.net to get a copy of this message
ID: 34120 Updated by: dmitry@php.net Reported By: ondrej at sury dot org -Status: Assigned +Status: Wont fix Bug Type: Scripting Engine problem Operating System: * PHP Version: 5CVS, 4CVS (2005-08-013) Assigned To: dmitry New Comment: Your oppinion makes sense. But I don't see a way to implement this. It is possible to allow use it as any argument or disallow as first argument near the same cost. I prefer first decision but not for 4.*, 5.*. Previous Comments: ------------------------------------------------------------------------ [2005-09-01 16:32:26] ondrej at sury dot org I disagree, this function should fail even when used as first argument (also according to docs). If you allow it to be passed as first argument, but not as second or third, etc., you create only chaos. It's much more cleaner to let it fail everytime. ------------------------------------------------------------------------ [2005-09-01 15:55:34] dmitry@php.net Right. I think this shouldn't be fixed. ------------------------------------------------------------------------ [2005-08-25 21:54:45] csaba at alum dot mit dot edu Note: Because this function depends on the current scope to determine parameter details, it may only appear in the first argument to a function. Thus myfunc1 (myfunc2 (func_get_arg(1), 7)) OK myfunc1 (myfunc2 (7, func_get_arg(0))) Error myfunc1 (7+func_get_arg(0)+func_get_arg(1)) OK myfunc2 (func_get_arg(0), func_get_arg(1)) Error If you must pass this value of func_get_arg() not in the first argument, assign the results to a variable, and pass the variable." Csaba Gabor from Vienna ------------------------------------------------------------------------ [2005-08-15 23:08:45] sniper@php.net Dmitry, this script should fail for all of those: <?php function doTitle($a = NULL, $b = NULL) { print "doTitle: $a, $b\n"; } function doHead() { doTitle(func_num_args()); doTitle(func_get_arg(0)); doTitle(func_get_args()); } doHead("1", "2"); ------------------------------------------------------------------------ [2005-08-13 20:23:35] sniper@php.net Manual says: "Note: Because this function depends on the current scope to determine parameter details, it cannot be used as a function parameter. If you must pass this value, assign the results to a variable, and pass the variable." ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/34120 -- Edit this bug report at http://bugs.php.net/?id=34120&edit=1

« previous php.bugs (#86847) next »