Hello, my name is Austin and this is my txt file
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
Hello World
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Read File</title>
<link rel="stylesheet" href="../css/styles.css">
</head>
<body>
<div class="page">
<p class="nav"><a href="../../index.php">Home</a></p>
<?php
// code
error_reporting(E_ALL); // set error reporting to all
echo("<h1>Austin's Code for Read File:</h1>");
$myFile = 'doc/text.txt';
if(file_exists($myFile)) // does file exist?
{
echo('File found! <br>');
$handle = fopen($myFile, 'r'); // try reading the file
if($handle)
{
echo('File is readable -- reading the file. <br><br>');
// read the contents of the counter file
$content = fread($handle, filesize($myFile));
fclose($handle);
$content = nl2br($content); // add new line breaks (i.e., <br>)
echo("<p> $content</p>");
}
else
{
echo("Cannot read the $myFile <br>");
}
}
else
{
echo('File NOT found! <br>');
}
?>
<hr>
<h2>Code follows</h2>
<div class="code"><?php highlight_file(__FILE__); ?></div>
<p class="nav nav-foot"><a href="../../index.php">Home</a></p>
</div>
</body>
</html>