PHP readfile() Function
Complete PHP Filesystem Reference Manual
Definition and Usage
The readfile() function reads a file and writes it to the output buffer.
Returns the number of bytes read from the file on success. On failure, returns FALSE with an error message. You can suppress the error output by prefixing the function name with '@'.
Syntax
readfile(filename,include_path,context)
| Parameters | Description |
|---|---|
| filename | Required. Specifies the file to read. |
| include_path | Optional. Set this parameter to '1' if you also want to search for the file in the include_path (in php.ini). |
| context | Optional. Specifies the context of the file handle. A context is a set of options that can modify the behavior of a stream. |
Tips and Notes
**Tip:** If "fopen wrappers" has been enabled in php.ini, you can use a URL as the file name in this function.
Example
The code above will output:
There are two lines in this file.
This is the last line.
57
Complete PHP Filesystem Reference Manual