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

From: Date: Thu, 01 Sep 2005 14:32:27 +0000
Subject: #34120 [Asn]: 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-84298@lists.php.net to get a copy of this message
ID: 34120 User updated by: ondrej at sury dot org Reported By: ondrej at sury dot org Status: Assigned Bug Type: Scripting Engine problem Operating System: * PHP Version: 5CVS, 4CVS (2005-08-013) Assigned To: dmitry New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [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." ------------------------------------------------------------------------ [2005-08-13 14:38:51] derick@php.net Well, that's true then. But I'm not sure how important this bug is :) ------------------------------------------------------------------------ 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 (#84298) next »