PHPファイル()関数
定義と使用法
ファイル()関数は、配列にファイル全体を読み込みます。
配列の各要素は含ま改行を含む1行でファイルです。
文法
file(path,include_path,context)
参数 | 描述 |
---|---|
path | 必需。规定要读取的文件。 |
include_path | 可选。如果您还想在 include_path(在 php.ini 中)中搜索文件的话,请设置该参数为 '1'。 |
context | 可选。规定文件句柄的环境。context 是一套可以修改流的行为的选项。若使用 NULL,则忽略。 |
ヒントと注意事項
ヒント:PHP 4.3で、この関数はバイナリセーフです。(バイナリ画像などのデータ()と文字データを書き込むために、この機能を使用できることを意味します。)
例
<?php
print_r(file("test.txt"));
?>
print_r(file("test.txt"));
?>
意志出力上のコード:
Array
(
[0] => Hello World. Testing testing!
[1] => Another day, another line.
[2] => If the array picks up this line,
[3] => then is it a pickup line?
)
(
[0] => Hello World. Testing testing!
[1] => Another day, another line.
[2] => If the array picks up this line,
[3] => then is it a pickup line?
)
PHPファイルシステムリファレンスマニュアルを完了