RE: [PHP] Re: unsetting a referenced parameter in a function

2009-07-23 Thread Arno Kuhl
-Original Message- From: Shawn McKenzie [mailto:nos...@mckenzies.net] Sent: 23 July 2009 02:36 PM To: php-general@lists.php.net Subject: Re: [PHP] Re: unsetting a referenced parameter in a function Tom Worster wrote: > On 7/22/09 6:09 PM, "Shawn McKenzie" wrote: > >

Re: [PHP] Re: unsetting a referenced parameter in a function

2009-07-23 Thread Martin Scotta
I think he is confusing the "unset" semantic. Unset just destroy a variable, but not the content of it. Take a look at the output of this simple script: function avoid_global_scope() { $a = 'foo'; var_dump( get_defined_vars() ); $b =& $a; var_dump( get_defined_vars() ); unset(

Re: [PHP] Re: unsetting a referenced parameter in a function

2009-07-23 Thread Shawn McKenzie
Tom Worster wrote: > On 7/22/09 6:09 PM, "Shawn McKenzie" wrote: > >> Tom Worster wrote: >>> though the manual is perfectly clear that this should be expected, i was a >>> bit surprised that the result of the following is 42 >>> >>> >> function foo(&$a) { >>> $a = 42; >>> unset($a); >>> $a

Re: [PHP] Re: unsetting a referenced parameter in a function

2009-07-22 Thread Martin Scotta
On Wed, Jul 22, 2009 at 9:27 PM, Tom Worster wrote: > On 7/22/09 6:09 PM, "Shawn McKenzie" wrote: > > > Tom Worster wrote: > >> though the manual is perfectly clear that this should be expected, i was > a > >> bit surprised that the result of the following is 42 > >> > >> >> function foo(&$a) {

Re: [PHP] Re: unsetting a referenced parameter in a function

2009-07-22 Thread Tom Worster
On 7/22/09 6:09 PM, "Shawn McKenzie" wrote: > Tom Worster wrote: >> though the manual is perfectly clear that this should be expected, i was a >> bit surprised that the result of the following is 42 >> >> > function foo(&$a) { >> $a = 42; >> unset($a); >> $a = 'meaning'; >> } >> foo($a); >

[PHP] Re: unsetting a referenced parameter in a function

2009-07-22 Thread Shawn McKenzie
Tom Worster wrote: > though the manual is perfectly clear that this should be expected, i was a > bit surprised that the result of the following is 42 > > function foo(&$a) { > $a = 42; > unset($a); > $a = 'meaning'; > } > foo($a); > print("$a\n"); > ?> > > normally i would expect unset()