__destruct() not called ! we shot us in the foot try the script
| From: | Ralph Deffke | Date: | Mon, 24 Aug 2009 23:40:13 +0000 |
| Subject: | __destruct() not called ! we shot us in the foot try the script | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-297157@lists.php.net to get a copy of this message | ||
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>";
?>