(PHP 5 >= 5.1.0)
SplFileObject::__construct — Construct a new file object.
Construct a new file object.
The file to read.
Даден URL може да бъде използван като име на файл с тази функция ако fopen wrappers е включено. Виж fopen() за повече подробности относно начина, по който се задава име на файл и List of Supported Protocols/Wrappers за списък с поддържаните 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.
Example #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; } ?>