-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:
>
>
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(
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
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) {
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);
>
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()
6 matches
Mail list logo