Class destructors : Destructors « Class « PHP






Class destructors

<?php
   class Book
   {
      private $title;
      private $isbn;
      private $copies;

      function __construct($isbn)
      {
         echo "<p>Book class instance created.</p>";
      }

      function __destruct()
      {
         echo "<p>Book class instance destroyed.</p>";
      }
   }

   $book = new Book("1111");

?>


           
       








Related examples in the same category

1.destuctor in action
2.Accessing instance-specific data within a destructor
3.Class with destructors
4.Cleaning Up with the __destruct Method (PHP 5 Only)
5.Defining an object destructor
6.Declaring and Using Object Constructors and Destructors