PHP readfile()関数
❮PHPファイルシステムリファレンス例
ファイルを読む:
<?php
echo readfile("test.txt");
?>
定義と使用法
readfile()関数はファイルを読み取り、それを出力バッファーに書き込みます。
ヒント: php.iniファイルでfopenラッパーが有効になっている場合は、この関数でURLをファイル名として使用できます。
構文
readfile(file, include_path, context)
パラメータ値
Parameter | Description |
---|---|
file | Required. Specifies the file to read |
include_path | Optional. Set this parameter to TRUE if you want to search for the file in the include_path (in php.ini) as well |
context | Optional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream |
技術的な詳細
戻り値: | 成功時に読み取られたバイト数、FALSEおよび失敗時にエラー。関数名の前に「@」を追加すると、エラーメッセージを非表示にできます。 |
---|---|
PHPバージョン: | 4.0以降 |
PHP変更ログ: | PHP 5.0:コンテキストサポートが追加されました |
❮PHPファイルシステムリファレンス