Forum Moderators: coopster

Message Too Old, No Replies

What does the ampersand in "&$varName" do?

         

neophyte

4:39 am on Sep 15, 2006 (gmt 0)

10+ Year Member



Hello All -

I've run across a php function script on the web which has an ampersand (&) infront of a number of vars passed to it.

Like this:

function thisFunc ($varOne, $varTwo, &$varThree, &$varFour)
{
do this;
do that;
...
}

I've never run across a VAR that's preceded by an '&' and am just wondering about it's functionality and in what cases is it appropriate to use.

Any enlightenment greatly appreciated.

Neophyte

eelixduppy

4:58 am on Sep 15, 2006 (gmt 0)



The & before the var means that it's a reference. More information in php.net's documentation titled References Explained [us2.php.net].

Good luck!

neophyte

11:03 pm on Sep 15, 2006 (gmt 0)

10+ Year Member



eelixduppy -

Thanks for the pointer and appreciate your assistance.

Neophyte