Sometimes it is required to show the contents of some text file to the web page. So we can change those contents easily without any problem.
First we will create a simple text file, with some contents.
name it as "test.txt"
These contents are saved in test.txt file.
I am showing you the contents of some text file.
Its very useful to show the contents of the text file in a browser.
Now we will create our php file which will show the contents of the test.txt file to the webpage.
$file = fopen("test.txt", "r");
$display = fgets($file, filesize("test.txt"));
echo $display . "
echo "Error occured ! ! ! Try again or report it to us";
Now when we execute this script, it will show the contents of the test.txt to our page.
In this script we are checking whether file exists or not, it it doesnt exists then we will show the error message. Tweet this!