Re: unset( $anobject) does not invoce __destruct()

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

 



see http://cn.php.net/manual/en/language.oop5.abstract.php
PHP 5 introduces abstract classes and methods. It is not allowed to
create an instance of a class that has been defined as abstract. Any
class that contains at least one abstract method must also be
abstract. Methods defined as abstract simply declare the method's
signature they cannot define the implementation.

You make misconception understand for abstract class,:(, correct code is:
abstract class a {
   abstract public function __construct(){

  }
  abstract public function __destruct(){

  }
 }

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

 $c = new b();
unset($c);

if you want to make it work correctly that you want,plase change code to follow
class c {
   public function __construct(){
    echo "constructing....<br/>";
  }
  public function __destruct(){
    echo "destructing....<br/>";
  }
}

 class d extends c{

 }
  $e = new d();
  unset($e);

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