Forum Moderators: coopster

Message Too Old, No Replies

function &somefunc()

         

lorax

7:25 pm on Jun 27, 2005 (gmt 0)

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



I've seen variables passed by reference in a function: function add_some_extra(&$string)

But I haven't had the opportunity to work with this example: function &somefunc()

First what is it? Second, how do you use it?

mcibor

10:00 pm on Jun 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To pass variable by reference you need to use ampersant in the function call, not in declaration
function func($var) {$var = 2;}
$a = 1;
func(&$a);//$a = 2

However such structure: &func I have never yet seen (I've seen @func - it is to suppress echoing to screen).

Interesting what that may be. Have you tried searching at www.php.net?

Best regards
Michal Cibor

jatar_k

10:19 pm on Jun 27, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I haven't seen that either lorax

would essentially be a ref to a function? weird

does it even work?

dreamcatcher

10:47 pm on Jun 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It is mentioned on the PHP website:

[php.net...]
[php.net...]

lorax

12:41 pm on Jun 29, 2005 (gmt 0)

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



So the value returned by the function is passed by reference?