downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

SplFileObject::current> <SplFileObject
[edit] Last updated: Sat, 07 Jan 2012

view this page in

SplFileObject::__construct

(PHP 5 >= 5.1.0)

SplFileObject::__constructConstruct a new file object.

설명

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

Construct a new file object.

인수

filename

The file to read.

Tip

fopen 래퍼를 활성화하면, 파일명으로 URL을 사용할 수 있습니다. 파일 이름을 지정하는 방법은 fopen()을 참고하십시오. 다양한 래퍼의 기능, 사용법, 제공하는 예약 정의 변수들에 대해서는 Supported Protocols and Wrappers를 참고하십시오.

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().

반환값

값을 반환하지 않습니다.

오류/예외

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

참고



add a note add a note User Contributed Notes SplFileObject::__construct
There are no user contributed notes for this page.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites