It's not that it's not allowed, it's that it should be done differently. You should make the function accept a reference in the definition, not pass in a reference to the function.

The manual page has a good, simple example on what to do.

http://www.php.net/manual/en/language.references.pass.php

Chris:

Interesting. One would think (at least I do) it should be the other way around.

Using the example given at the link above:

<?php
function foo(&$var)
{
   $var++;
}

$a=5;
foo($a);
// $a is 6 here
?>

We have one function that works one way.

<?php
function foo($var)
{
   $var++;
}

$a=5;
foo(&$a);
// $a is 6 here
?>

However, doing it this way, the function can serve two purposes. I can send it a reference or I could send it a value. I know that in this function a value doesn't do anything, but it could if the function was different.

Plus, in the first function, I can't send it a reference (i.e., a reference to a reference?).

What's short reasoning for this being recommended this way? What am I not seeing?

tedd
--
--------------------------------------------------------------------------------
http://sperling.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to