Display Text File Content In The Page Using PHP

This is a continuation of previous tutorial on Save Data To Text File Using PHP. This tutorial will teach you on how to display text file content in our page using PHP. The feature of this program is it allows you to echo or output all the save in our text file. Follow the details bellow on how to this code.

Creating Our Script that Display text file Content

The code bellow includes the link source of our text file. I used nl2br and file_get_contents to display the text file contents. nl2br is a function that inserts HTML line breaks before all newlines in a string. Copy the code bellow and save it as "index.php".
  1. <?php  
  2.         $filename='informationlist.txt';
  3.     echo nl2br(file_get_contents($filename));
  4.     echo "<br></br>";
  5. ?>
That's it you've been successfully created a script that allows you to display text file content using php.

Comments

this is exactly what i was looking for. thanks a lot.

Add new comment