<html>
<! BasicObject2.php                                           >
<! Chapter 8, Oracle Database XE PHP Web Programming          >
<! by Michael McLaughlin                                      >
<!                                                            >
<! This script declares and instantiate a class with an       >
<! overriding __construct() function.                         >
<head>
<title>
  Chapter 8 : BasicObject2.php
</title>
</head>
<body>
<?php
  // Declare a variable to hold an object instance.
  $myObject = new BasicObject("Instance of Basic Object");

  // Define a class that prints a message.
  class BasicObject
  {
    // Declare default instance variables.
    private $name = "BasicObject";

    function __construct($variable)
    {
      // Check for valid runtime parameter.
      if (isset($variable))
      {
        // Message on entrance.
        print "[Constructing Instance [".$variable."]<br>";

        // Reset class variable to instance variable.
        $this->name = $variable;
      }
    }

    function __destruct()
    {
      // Message on exit.
      print "[Destructing Instance [".$this->name."]<br>";
    }
  }
?>
</body>
</html>
