ファイルシステム関数
| 解説 | ファイルを出力する |
|---|---|
| 書式 | int readfile( string filename [, bool use_include_path ] ) |
int readfile( string ファイル名 [, bool インクルードパス ] ) |
|
| 引数 |
filename
ファイル名
|
use_include_path
インクルードパスを検索するかどうか
|
|
| 返値 | 読み込んだバイト数/FALSE(読み込み失敗) |
readfile()は、指定したファイル内容を全読み込んで標準出力に出力する関数です。標準出力とはWebサーバでPHPを動作させている場合にWebブラウザとなります。
filename
ファイル名
use_include_path
インクルードパス
参考関数
file_get_contents()---- ファイルの内容を全て取得するfile()---- ファイルの内容を全て取得して配列に格納するfpassthru()---- 現在のファイルポインタの位置以降全てのデータを出力する
サンプルスクリプト
簡単な利用例
<?php
readfile('somefile.txt')
?>
ファイルの内容をすべて出力
<?php
$fp = @fopen("test.php", "r");
while( ! feof( $fp ) ){
echo fgets( $fp, 9182 ) . "<br>";
}
fclose($fp);
?>


