(PHP 5 >= 5.1.0)
SplFileObject::__construct — Construct a new file object.
Construct a new file object.
The file to read.
fopen wrappers が有効の場合、この関数のファイル名として URL を使用することができます。ファイル名の指定方法に関する詳細は fopen()、サポートされる URL プロトコルの種類 については、(例えば)サポートするプロトコル/ラッパー を参照してください。
The mode in which to open the file. See fopen() for a list of allowed modes.
Whether to search in the include_path for filename .
A valid context resource created with stream_context_create().
値を返しません。
Throws a RuntimeException if the filename cannot be opened.
例1 SplFileObject::__construct example
This example opens the current file and iterates over its contents line by line.
<?php
$file = new SplFileObject(__FILE__);
foreach ($file as $line) {
echo $line;
}
?>
上の例の出力は、 たとえば以下のようになります。
<?php $file = new SplFileObject(__FILE__); foreach ($file as $line) { echo $line; } ?>