<html>
<! GetFileByLines.php                                         >
<! Chapter 10, Oracle Database XE PHP Web Programming         >
<! by Michael McLaughlin                                      >
<!                                                            >
<! This script demonstrates how to read a file line-by-line   >
<! into a file and render it in a webpage.                    >
<head>
<title>
  Chapter 10 : GetFileByLines.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 = array();

  // Check for a valid read-only file handle.
  if ($fp = fopen($directory.$fname,'r'))
  {
    // Read to end-of-file by lines.
    while (!feof($fp))
      $contents[] = fgets($fp)."<br>";

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

  // Read and print the file by buffer chunks.
  foreach ($contents as $key => $value)
    print $value;
?>
</body>
</html>
