<html>
<! ScalarVariables.php                                        >
<! Chapter 4, Oracle Database XE PHP Web Programming          >
<! by Michael McLaughlin                                      >
<!                                                            >
<! This script demonstrates scalar variable explicit casting. >
<head>
<title>
  Chapter 4 : ScalarVariables.php
</title>
<style>
.normal {font-family:Courier;font-style:normal;font-weight:normal;
         font-size:12pt;color:#000000;background-color:#ffffff};
</style>
</head>
<body>
<?php
  // Declare variables by assigning a value with explict type casting.
  $myVar1 = (boolean) 2.123;  // Explicit cast to boolean.
  $myVar2 = (int) 2.823;      // Explicit cast to integer.
  $myVar3 = (float) 2.123;    // Implicit cast to double.
  $myVar4 = (double) 2.123;   // Explicit cast to double.
  $myVar5 = (string) 2.123;   // Explicit cast to string.

  // Print and format variables to the web page.
  print "<font class=normal>";
  print "\$myVar1 [" . gettype($myVar1) . "] [" . $myVar1 . "]<br>\n";
  print "\$myVar2 [" . gettype($myVar2) . "] [" . $myVar2 . "]<br>\n";
  print "\$myVar3 [" . gettype($myVar3) . "] [" . $myVar3 . "]<br>\n";
  print "\$myVar4 [" . gettype($myVar4) . "] [" . $myVar4 . "]<br>\n";
  print "\$myVar5 [" . gettype($myVar5) . "] [" . $myVar5 . "]<br>\n<p>\n";
  print "</font>";

  $myVar6 = &$myVar5;
  settype($myVar6,"boolean");

  print "\$myVar5 [" . gettype($myVar5) . "] [" . $myVar5 . "]<br>\n";

?>
</body>
</html>
