__destruct() not called ! we shot us in the foot try the script

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

 



well I would call this an error in the first view , and some of u where
right! and the stuff with the refernce counter seems to be right as well.

however I can't see a reason for it as 5.x works through refernces. so
unsetting a REFERENCE to the object does not destroy it.

How to destroy the object then?

<?php


abstract class a {
  public function __construct(){
    echo "constructing....<br>";
  }
  public function __destruct(){
    echo "destructing....<br>";
  }
}

class b extends a{

  public function doSomething(){
    echo "I'm doing ...but the reference c to the object is unset()<br>";
  }

}

$c = new b();

$d = $c ;   // works
$f[] = $c ; // works

class e {
  public static $m;

  public static function setM( $m ){
    self::$m = $m;
  }
}

$o = new e();
e::setM( $c ); // works

echo "unsetting ...<br>";
unset( $c );

$d->doSomething();

echo "script ending now ...<br>";

?>




-- 
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