Reads from a file.
The fread() function reads a number of bytes from a file and returns them as a string.
<?php
$filename = "log.txt";
$logfile = fopen($filename, "r");
$data = fread($logfile, filesize($filename));
print nl2br($data);
?> Sample code running
Sample code running
Sample code running
Sample code running The code prints the contents of a log file to the browser. Since the log file contains new line characters that will not show in a web browser, nl2br() is used to convert them to html tags.