FileStream
extends Stream
in package
Class for working with file streams.
Table of Contents
Properties
- $_length : int
- The length of the stream.
- $_stream : mixed
- The stream descriptor.
- $_virtual : bool
- Indicates if the file is virtual.
Methods
- __construct() : mixed
- Constructor.
- __destruct() : mixed
- Destructor.
- __get() : mixed|null
- Getter.
- close() : void
- Close the stream.
- Close() : void
- Closes the stream.
- flush() : void
- Save changes.
- Flush() : void
- Flushes the stream.
- Read() : string|bool
- Reads from the stream.
- ReadLine() : bool|string
- Reads a line from the stream.
- Seek() : void
- Moves the position within the stream.
- Write() : bool|int
- Writes to the stream.
- WriteLine() : bool|int
- Writes a line to the stream.
Properties
$_length
The length of the stream.
protected
int
$_length
= 0
$_stream
The stream descriptor.
protected
mixed
$_stream
$_virtual
Indicates if the file is virtual.
protected
bool
$_virtual
Methods
__construct()
Constructor.
public
__construct(string $source[, bool $virtual = false ]) : mixed
Parameters
- $source : string
-
The file source.
- $virtual : bool = false
-
Indicates if the file is virtual.
__destruct()
Destructor.
public
__destruct() : mixed
__get()
Getter.
public
__get(string $property) : mixed|null
Parameters
- $property : string
-
The property name.
Return values
mixed|null —The value of the property.
close()
Close the stream.
public
abstract close() : void
Close()
Closes the stream.
public
Close() : void
flush()
Save changes.
public
abstract flush() : void
Flush()
Flushes the stream.
public
Flush() : void
Read()
Reads from the stream.
public
Read([int|null $offset = 0 ][, int|null $count = 0 ]) : string|bool
Parameters
- $offset : int|null = 0
-
The offset from where to start reading.
- $count : int|null = 0
-
The number of bytes to read.
Return values
string|bool —The content read from the stream.
ReadLine()
Reads a line from the stream.
public
ReadLine() : bool|string
Return values
bool|string —The line read from the stream.
Seek()
Moves the position within the stream.
public
Seek([int $offset = 0 ]) : void
Parameters
- $offset : int = 0
-
The offset to move the position.
Write()
Writes to the stream.
public
Write(string $buffer[, int|null $offset = 0 ]) : bool|int
Parameters
- $buffer : string
-
The content to write.
- $offset : int|null = 0
-
The position from where to write.
Return values
bool|int —The number of bytes written or false on failure.
WriteLine()
Writes a line to the stream.
public
WriteLine(mixed $string) : bool|int
Parameters
- $string : mixed
-
The string to write.
Return values
bool|int —The number of bytes written or false on failure.