Re: return

From: Date: Mon, 01 Apr 2002 19:19:51 +0000
Subject: Re: return
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-90999@lists.php.net to get a copy of this message
On Mon, 1 Apr 2002, 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); If you don't have the & in the function declaration, then the function operates on a copy of the variable. This is normally more useful, when you don't want functions messing with your variables, but instead doing things with them to produce new information (which you get back via return). miguel

« previous php.general (#90999) next »