<html>
<! BasicObject3.php                                           >
<! Chapter 8, Oracle Database XE PHP Web Programming          >
<! by Michael McLaughlin                                      >
<!                                                            >
<! This script declares and instantiate a class with the      >
<! default __construct() and __destruct functions and a       >
<! set_variables() instance function.                         >
<head>
<title>
  Chapter 8 : BasicObject3.php
</title>
</head>
<body>
<?php
  // Declare an object instance.
  $myObject = new BasicObject();

  // Print line break.
  print "<hr>";

  // Reset the class instance variables.
  $myObject->set_variables("Reset Private"
                          ,"Reset Protected"
                          ,"Reset Public");

  // Define a class that prints a message.
  class BasicObject
  {
    // Declare class variables.
    private $myPrivate = "Privately Scoped Variable";
    protected $myProtected = "Protected Scoped Variable";
    public $myPublic = "Public Scoped Variable";

    public function __construct()
    {
      // Message on entrance.
      print "This is an [".__CLASS__."] instance.<br>";
      print "<hr>";
      print "Private Variable [".$this->myPrivate."]<br>";
      print "Protected Variable [".$this->myProtected."]<br>";
      print "Public Variable [".$this->myPublic."]<br>";
    }

    public function __destruct()
    {
      // Message on entrance.
      print "Private Variable [".$this->myPrivate."]<br>";
      print "Protected Variable [".$this->myProtected."]<br>";
      print "Public Variable [".$this->myPublic."]<br>";
    }

    public function set_variables($private,$protected,$public)
    {
      $this->myPrivate = $private;
      $this->myProtected = $protected;
      $this->myPublic = $public;
    }
  }
?>
</body>
</html>
