PHP readfile () function
Definition and Usage
readfile () function to read a file and written to the output buffer.
If successful, the function returns the number of bytes read from the file. If this fails, the function returns FALSE with an error message. You can add a function name in front of the '@' to hide the error output.
grammar
readfile(filename,include_path,context)
参数 | 描述 |
---|---|
filename | 必需。规定要读取的文件。 |
include_path | 可选。如果您还想在 include_path(在 php.ini 中)中搜索文件的话,请设置该参数为 '1'。 |
context | 可选。规定文件句柄的环境。context 是一套可以修改流的行为的选项。 |
Tips and Notes
Tip: If the "fopen wrappers" have been enabled in the php.ini file, you can function in the present URL as a filename with.
Examples
<?php
echo readfile("test.txt");
?>
echo readfile("test.txt");
?>
The code above will output:
There are two lines in this file.
This is the last line.
57
This is the last line.
57
Complete PHP Filesystem Reference Manual