PHPCap API

FileUtil
in package

File utility class for dealing with files.

Table of Contents

appendStringToFile()  : mixed
Appends the specified string to the specified file.
fileToString()  : string
Reads the contents of the specified file and returns it as a string.
getErrorHandler()  : ErrorHandlerInterface
Gets the error handler for the class.
setErrorHandler()  : mixed
Sets the error handler used for methods in this class.
writeStringToFile()  : mixed
Writes the specified string to the specified file.

Methods

appendStringToFile()

Appends the specified string to the specified file.

public static appendStringToFile(string $string, string $filename) : mixed
Parameters
$string : string

the string to append.

$filename : string

the name of the file that is appended.

Tags
throws
PhpCapException

if an error occurs.

Return values
mixed

false on failure, and the number of bytes appended on success.

fileToString()

Reads the contents of the specified file and returns it as a string.

public static fileToString(string $filename) : string
Parameters
$filename : string

the name of the file that is to be read.

Tags
throws
PhpCapException

if an error occurs while trying to read the file.

Return values
string

the contents of the specified file.

writeStringToFile()

Writes the specified string to the specified file.

public static writeStringToFile(string $string, string $filename[, bool $append = false ]) : mixed
Parameters
$string : string

the string to write to the file.

$filename : string

the name of the file to write the string.

$append : bool = false

if true, the file is appended if it already exists. If false, the file is created if it doesn't exist, and overwritten if it does.

Tags
throws
PhpCapException

if an error occurs.

Return values
mixed

false on failure, and the number of bytes written on success.

Search results