Re: return

From: Date: Mon, 01 Apr 2002 19:24:45 +0000
Subject: Re: return
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-91001@lists.php.net to get a copy of this message
On Monday, April 1, 2002, at 02:13 PM, Jordan K. Martin wrote:
Makes sense. I didn't think much when writing that piece...but...what is the & for? wouldn't it work the same without it? function test ($var) {
    $var = addslashes($var)
} $foo = "He's dreaming"; test($foo); print($foo);
No, this won't work because you're not returning a value. You need to either have a return statement in this function that says "return $var;" or you need to use the & sign, which lets you change the value of a variable outside the namespace of the function. Or scope. I forget which it is. Try your above code -- it shouldn't work. Erik ---- Erik Price Web Developer Temp Media Lab, H.H. Brown pricee@hhbrown.com

« previous php.general (#91001) next »