Re: [PHP] Re: destroying objects in an array in PHP5

2004-07-27 Thread Erik Franzén
Thanxs for the help Curt!! Thats a tricky solution, but it works... This is almost motivating a new method in PHP5: $foo->__destroy() which will destroy the object once and for all... :) /Erik Curt Zirzow wrote: * Thus wrote Erik Franzn: $oObjectB[$i] = &$oObjectA[$i]; The above statement does no

Re: [PHP] Re: destroying objects in an array in PHP5

2004-07-27 Thread Matthew Sims
> > This is not true. PHP 5 passes objects by reference to functions > only. Assignments are treated the same way as php4 externally. > > > /* note: no &$f */ > function testfoo($f) { > $f->foo = 'testfoo'; > } > > class foo { public $foo; } > > /* object is passed by reference */ > $a = new f

Re: [PHP] Re: destroying objects in an array in PHP5

2004-07-27 Thread Curt Zirzow
* Thus wrote Erik Franzn: > $oObjectB[$i] = &$oObjectA[$i]; > > The above statement does not matter, because in PHP5 "objects are > referenced by handle, and not by value". This is not true. PHP 5 passes objects by reference to functions only. Assignments are treated the same way as php4 extern

Re: [PHP] Re: destroying objects in an array in PHP5

2004-07-27 Thread Matthew Sims
> > The object is not destroyed!? How do I destroy it without calling > unset($b)? > Not sure if this is your solution but have you looked in to destructors? Half down this page it explains: http://us4.php.net/migration5.oop -- --Matthew Sims -- -- PHP General Mailing

Re: [PHP] Re: destroying objects in an array in PHP5

2004-07-27 Thread Erik Franzén
$oObjectB[$i] = &$oObjectA[$i]; The above statement does not matter, because in PHP5 "objects are referenced by handle, and not by value". Look at this example: $a = new foo(); $b = $a; unset($a); var_dump($b); >? This will output: object(foo)#1 (0) { } The object is not destroyed!? How do I destr

Re: [PHP] Re: destroying objects in an array in PHP5

2004-07-27 Thread Matt M.
On Tue, 27 Jul 2004 21:22:05 +0200, Erik Franzén <[EMAIL PROTECTED]> wrote: > I am correcting myself... > > class foo {} > > $oObjectA = array(); > $oObjectB = array(); > > for($i=0;$i<2;$i++) { > $oObjectA[$i] = new foo(); > $oObjectB[$i] = $oObjectA[$i]; > } > > unset($oObjectA[1]);