PHP Function Readfile
Whether it’s grabbing and echoing a Web page or parsing HTML or XML content from a remote server PHP provides a wealth of effective file processing functions. While classic functions like fread might serve you well much of the time more sophisticated functionality can be found in things like fgets and fparse.
The php function readfile allows you to take the contents of a specified file and write them to an output buffer. This function takes three parameters; filename, path and context. The first parameter is a mandatory field where you provide the name of the file that you want to read and the second one is an optional boolean value which specifies if the reading should start at the beginning or end of the file.
If you specify a positive number for the second argument, the reading will begin at that position within the original file. This could be useful if you are using a file for recording data such as a diary. It will prevent your current records from overwriting anything that has been recorded previously.
The php function readfile() is suitable for a variety of different purposes, but it is not suitable for reading large files into memory. If you need to read large files into memory then it is better to use the fgets() and fread() functions instead. Ensure that you turn off output buffering before calling readfile() if it is necessary to do so.