SplFileObject
PHP Manual

SplFileObject::__construct

(PHP 5 >= 5.1.0)

SplFileObject::__constructConstruct a new file object.

Açıklama

SplFileObject::__construct ( string $filename [, string $open_mode = "r" [, bool $use_include_path = false [, resource $context ]]] )

Construct a new file object.

Değiştirgeler

filename

The file to read.

İpucu

fopen sarmalayıcıları etkin kılınmışsa bu işlevde dosya ismi olarak bir URL belirtebilirsiniz. Desteklenen URL protokollerinin listesi ve dosya isminin nasıl belirtilebileceği hakkında bilgi edinmek için fopen() işlevine bakınız.

open_mode

The mode in which to open the file. See fopen() for a list of allowed modes.

use_include_path

Whether to search in the include_path for filename .

context

A valid context resource created with stream_context_create().

Dönen Değerler

Hiçbir değer dönmez.

Hatalar/İstisnalar

Throws a RuntimeException if the filename cannot be opened.

Örnekler

Örnek 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;
}
?>

Yukarıdaki örnek şuna benzer bir çıktı üretir:

<?php
$file = new SplFileObject(__FILE__);
foreach ($file as $line) {
    echo $line;
}
?>

Ayrıca Bakınız


SplFileObject
PHP Manual