note 44944 deleted from function.func-get-arg by tomsommer

From: Date: Fri, 20 Aug 2004 21:25:24 +0000
Subject: note 44944 deleted from function.func-get-arg by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-75029@lists.php.net to get a copy of this message
Note Submitter: dave at corecomm dot us ---- 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.

« previous php.notes (#75029) next »