At 1:24 PM -0500 4/6/06, Chris Boget wrote:
Is there a way to test to see if a function argument was passed by
reference instead of by value?
thnx,
Chris
Chris:
As I am sure you know, passing by reference is simply passing the
memory address of the variable to a function instead of it's value.
If the receiving function does something to the variable at that
address, then the value at that address is changed. You can test this
by simply checking the value before and after it's returned from the
function.
For example, the following just passes the memory address of variable
$a to a function. After which, the function alters the variable at
that memory address, but doe not return a value. But, echoing the
variable after the function call shows that the variable has indeed
been altered.
<?php
$a = 10;
echo("$a <br/>");
ref(&$a);
echo("$a");
?>
<?php
function ref($a)
{
$a--;
}
?>
HTH's
tedd
--
--------------------------------------------------------------------------------
http://sperling.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php