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
Last updated: Fri, 20 May 2011

view this page in

SplFileObject::__construct

(PHP 5 >= 5.1.0)

SplFileObject::__constructConstruct a new file object.

Descripción

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

Construct a new file object.

Parámetros

filename

The file to read.

Tip

Se puede usar una dirección URL como nombre de archivo con esta función si los fopen wrappers han sido activados. Consulte fopen() para más información de como especificar el nombre de fichero. Consulte Protocolos y Envolturas soportados para ver enlaces con información sobre las diferentes habilidades que los wrappers tienen, notas de uso e información de cualquier variables predefinidas que pueden usarse.

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

Valores devueltos

No devuelve ningún valor.

Errores/Excepciones

Throws a RuntimeException if the filename cannot be opened.

Ejemplos

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

El resultado del ejemplo sería algo similar a:

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

Ver también



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