<html>
<! GetFileByCharacters.php                                    >
<! Chapter 10, Oracle Database XE PHP Web Programming         >
<! by Michael McLaughlin                                      >
<!                                                            >
<! This script demonstrates how to read a file character-by-  >
<! character and then render the contents into a web page.    >
<head>
<title>
  Chapter 10 : GetFileByCharacters.php
</title>
</head>
<body>
<?php
  // Set directory and backquote directory delimiters.
  $directory = "C:\\php\\";

  // Set the file name.
  $fname = "php.ini";

  // Declare an array to hold character buffers.
  $contents = "";

  // Check for a valid read-only file handle.
  if ($fp = fopen($directory.$fname,'r'))
  {
    // Read to end-of-file by character.
    while (!feof($fp))
      $contents .= fgetc($fp);

    // Close the open file handle.
    fclose($fp);
  }

  // Print the string containing the file characters.
  print $contents;
?>
</body>
</html>
