The readfile() function reads a file and writes it to the output buffer.
If successful, the function returns the number of bytes read from the file. If it fails, the function returns FALSE with an error message. You can hide error output by adding an '@' in front of the function name.
readfile(filename,include_path,context)
parameter | describe |
---|---|
filename | Required. Specifies the file to be read. |
include_path | Optional. Set this parameter to '1' if you also want to search for files in include_path (in php.ini). |
context | Optional. Specifies the environment for a file handle. context is a set of options that can modify the behavior of the stream. |
Tip: If "fopen wrappers" has been activated in the php.ini file, you can use the URL as the file name in this function.
<?phpecho readfile("test.txt");?>
The above code will output:
There are two lines in this file.This is the last line.57