Class with destructors : Destructors « Class « PHP






Class with 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("111111111111");
?>
  
  








Related examples in the same category

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