Forum Moderators: coopster

Message Too Old, No Replies

& before a variable / function etc

can someone explain or point to a tutorial please

         

proper_bo

10:17 am on Nov 2, 2005 (gmt 0)

10+ Year Member



I have been looking around for a tutorial about the effects and reasons for placing an & (&) before a variable, function, etc in php. Obviously it isn't easy to find one as its difficult to search for the one character.

could someone explain what the & symbol does or point me to a post / site that does.

Thank you.

grandpa

10:32 am on Nov 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



& is a reference to a variable. Normally a variable will be static, the reference allows you to access the same variable content by different names. If I understood what I just said I might be able to help explain the reference a little better..

References Explained [us3.php.net]

There are other references available in PHP. $this is a reference used with an object (or a class). Actually, here's the correct definition:
In an object method, $this is always a reference to the caller object.

proper_bo

11:24 am on Nov 2, 2005 (gmt 0)

10+ Year Member



Thanks Grandpa (never thought I would say that again at my age!)
That exactly what I needed.
Don't you hate it when you don't know the name of what your looking for and you end up trying all sorts of words to describe it.

Cheers.

grandpa

11:34 am on Nov 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yeah, I hate that. And I remembered how much trouble I had locating that information the first time. Glad to help.