PHP file()関数
❮PHPファイルシステムリファレンス例
ファイルを配列に読み込みます。
<?php
print_r(file("test.txt"));
?>
定義と使用法
file()は、ファイルを配列に読み込みます。
各配列要素には、ファイルからの行が含まれ、改行文字が付加されたままになります。
構文
file(filename, flag, context)
パラメータ値
Parameter | Description |
---|---|
filename | Required. Specifies the path to the file to read |
flag |
Optional. Can be one or more of the following constants:
|
context | Optional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream. Can be skipped by using NULL. |
技術的な詳細
戻り値: | 配列内のファイル全体、失敗した場合はFALSE |
---|---|
PHPバージョン: | 4.0以降 |
バイナリセーフ: | はい、PHP4.3では |
❮PHPファイルシステムリファレンス