Rasmus, 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); Jordan K. Martin http://www.newimagedesign.com "Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Well, you could do it without a return, but first, addslashes() returns > the modified string, it does not do in-place replacement. And second, you > would need to pass the string in by reference, like this: > > function test (& $var) > { > $var = addslashes($var) > } > > $foo = "He's dreaming"; > test($foo); > print($foo); > > -Rasmus > > On Mon, 1 Apr 2002, Jordan wrote: > > > Eric, > > > > Isnt there really no need for the 'return' though? > > > > $test ($var) > > { > > addslashes($var) > > } > > > > $foo = "He's dreaming"; > > $foo = test($foo); > > print($foo); > > //should also print He\'s dreaming > > > > Am I incorrect in thinking this? > > > > -Jordan K. Martin > > http://www.newimagedesign.com > > > > > > Eric Coleman <[EMAIL PROTECTED]> wrote in message > > 018e01c1d93d$cd404be0$0201a8c0@zaireweb">news:018e01c1d93d$cd404be0$0201a8c0@zaireweb... > > > But to answer your question > > > > > > The purpose of return, is to "return" a value.. > > > > > > function test($var) > > > { > > > return addslashes($var); > > > } > > > > > > $foo = "Yes, I'am Very Awsome"; > > > $foo = test($foo); > > > echo($foo); > > > // echo's, Yes I\'am Very Awsome > > > > > > Understand? > > > > > > ----- Original Message ----- > > > From: "Rasmus Lerdorf" <[EMAIL PROTECTED]> > > > To: "Gary" <[EMAIL PROTECTED]> > > > Cc: <[EMAIL PROTECTED]> > > > Sent: Sunday, March 31, 2002 11:43 PM > > > Subject: Re: [PHP] return > > > > > > > > > > Nope, that code makes no sense. $_POST is an array containing the POST > > > > variables. You make a copy of that array an put it in $foo thereby > > > > overwriting the passed in $foo. Then you return $$foo which actually > > ends > > > > up returning a variable named $Array. It does not look like you have a > > > > $Array variable in scope, and it is surely not what the misguided coder > > > > behind this code was trying to achieve. In short, this is completely > > > > bogus. > > > > > > > > -Rasmus > > > > > > > > On Sun, 31 Mar 2002, Gary wrote: > > > > > > > > > Can someone explain to me the reason for using return. > > > > > > > > > > function _getValue($foo) > > > > > { > > > > > $foo = $_POST; > > > > > return ${$foo}; > > > > > } > > > > > > > > > > TIA > > > > > Gary > > > > > > > > > > > > > > > -- > > > > > PHP General Mailing List (http://www.php.net/) > > > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php