<html>
<! MathAdd.php                                                >
<! Chapter 4, Oracle Database XE PHP Web Programming          >
<! by Michael McLaughlin                                      >
<!                                                            >
<! This script demonstrates math principles in PHP.           >
<head>
<title>
  Chapter 4 : MathAdd.php
</title>
</head>
<body>
<?php
  // Include the arithmetic display library.
  include("DisplayLibrary.php");

  // Declare int variables.
  $myIntVar1 = 17;
  $myIntVar2 = 23;

  // Declare float variable Pi.
  $myFloatVar = 22/7;

  // Define two variables without type definition.
  $myInteger;
  $myFloat;

  // Get an integer by adding two integers.
  $myInteger = $myIntVar1 + $myIntVar2;

  // Display math operation.
  display_add_results('$myInteger',$myInteger
                     ,'$myIntVar1',$myIntVar1
                     ,'$myIntVar2',$myIntVar2);

  // Get a float when one integer is cast as a float.
  $myInteger = $myIntVar1 + (float) $myIntVar2;

  // Display math operation.
  display_add_results('$myInteger',$myInteger
                     ,'$myIntVar1',$myIntVar1
                     ,'(float) $myIntVar2',(float) $myIntVar2);

  // Get a float when one integer is cast as a float.
  $myInteger = $myIntVar1 + $myFloatVar;

  // Display math operation.
  display_add_results('$myInteger',$myInteger
                     ,'$myIntVar1',$myIntVar1
                     ,'$myFloatVar',$myFloatVar);
?>
</body>
</html>
