note 44944 added to function.func-get-arg

From: Date: Fri, 20 Aug 2004 20:49:14 +0000
Subject: note 44944 added to function.func-get-arg
Groups: php.notes 
Request: Send a blank email to php-notes+get-75019@lists.php.net to get a copy of this message
To clarify and enhance Mightye's comment, func_get_arg() always returns a value, even when the parameter to which it refers was declared and passed by reference. This code: <?php function foo(&$bar) { $baz=func_get_arg(0); $baz++; echo "Within the function, bar=$bar, baz=$baz and func_get_arg(0)=".func_get_arg(0)."\r\n"; } $x=1; echo "Before the function, x=$\r\n"; foo($x); echo "After the function, x=$x\r\n"; ?> ...generates this output: Before the function, x=1 Within the function, bar=1, baz=2 and func_get_arg(0)=1 After the function, x=1 If $baz had got the same reference $bar did in the function, they (and $x in caller scope) would all increment. ---- Manual Page -- http://www.php.net/manual/en/function.func-get-arg.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44944 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44944&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44944&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#75019) next »