<html>
<! Comparing.php                                              >
<! Chapter 8, Oracle Database XE PHP Web Programming          >
<! by Michael McLaughlin                                      >
<!                                                            >
<! This script declares, and instantiate two classes, using   >
<! the Address.inc Address class library, then it compares    >
<! the two classes, which are unequal.                        >
<head>
<title>
  Chapter 8 : Comparing.php
</title>
</head>
<body>
<?php
  // Include a library class.
  include_once("Address.inc");

  // Declare a variable to hold an object instance.
  $myAddress1 = new Address("Joseph","McLaughlin"
                           ,"1111 Broadway","Oakland","CA","94601");

  // Print instance contents.
  print $myAddress1->get_address();

  // Insert paragraph return.
  print "<p>";

  // Clone a copy of an object.
  $myAddress2 = clone $myAddress1;

  // Update first name.
  $myAddress2->set_first_name("Ariel");

  // Print instance contents.
  print $myAddress2->get_address();

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

  // Print whether they are equal.
  print "[\$myAddress1] and [\$myAddress2] are ";
  print "[".compare($myAddress1,$myAddress2)."].";

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

  // Call the __toString() function.
  print $myAddress1->__toString();

  // Substitue a string for true or false.
  function compare(&$obj1,&$obj2)
  {
    // Compare the objects.
    if ($obj1->equals($obj2))
      return "equal";
    else
      return "not equal";
  }
?>
</body>
</html>
