Re: Array references - how to unset() ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hack988 hack988 wrote:
Reference vars in php would not be unset if it reference by another
var,so you must keep original var had'nt being reference.

You can't reference a reference in PHP. If you take the reference of a variable that is itself a reference then you are taking a reference to the referenced value and not the reference variable itself. This is illustrated in the following example:

<?php

$foo = '123';
$fee = '987';

$blah = &$foo;
$bleh = &$blah;
$blah = &$fee;

echo 'blah: '.$blah."\n";
echo 'bleh: '.$bleh."\n";

?>

What I think you meant to say, is that a value is not unset as long as it has at least one variable referencing it. You most certainly unset the reference if you apply unset to it, it is the value referenced that may remain.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux