PHP readfile() 函數(shù)
定義和用法
readfile() 函數(shù)輸出一個(gè)文件。
該函數(shù)讀入一個(gè)文件并寫入到輸出緩沖。
若成功,則返回從文件中讀入的字節(jié)數(shù)。若失敗,則返回 false。您可以通過 @readfile() 形式調(diào)用該函數(shù),來隱藏錯(cuò)誤信息。
語法
readfile(filename,include_path,context)
參數(shù) | 描述 |
---|---|
filename | 必需。規(guī)定要讀取的文件。 |
include_path | 可選。如果也想在 include_path 中搜索文件,可以使用該參數(shù)并將其設(shè)為 true。 |
context | 可選。規(guī)定文件句柄的環(huán)境。Context 是可以修改流的行為的一套選項(xiàng)。 |
說明
對 context 參數(shù)的支持是 PHP 5.0.0 添加的。
提示和注釋
提示:如果在 php.ini 文件中 "fopen wrappers" 已經(jīng)被激活,則在本函數(shù)中可以把 URL 作為文件名來使用。
例子
<?php echo readfile("test.txt"); ?>
輸出:
There are two lines in this file. This is the last line. 57