Convenience class for reading, writing and appending to files.
Methods | ||||||||
---|---|---|---|---|---|---|---|---|
public
|
__construct(string $path, boolean $create = false, integer $mode = 0755)
Constructor
Constructor Parameters
|
# | ||||||
public
|
__destruct()
Closes the current file if it is opened
Closes the current file if it is opened |
# | ||||||
public
|
create(): boolean
Creates the File.
Creates the File. ReturnsSuccess |
# | ||||||
public
|
open(string $mode = 'r', boolean $force = false): boolean
Opens the current file with a given $mode
Opens the current file with a given $mode Parameters
ReturnsTrue on success, false on failure |
# | ||||||
public
|
read(bool|string|int $bytes = false, string $mode = 'rb', boolean $force = false): mixed
Return the contents of this File as a string.
Return the contents of this File as a string. Parameters
Returnsstring on success, false on failure |
# | ||||||
public
|
offset(mixed $offset = false, integer $seek = SEEK_SET): mixed
Sets or gets the offset for the currently opened file.
Sets or gets the offset for the currently opened file. Parameters
ReturnsTrue on success, false on failure (set mode), false on failure or integer offset on success (get mode) |
# | ||||||
public
|
prepare(string $data): string
Prepares a ascii string for writing
fixes line endings
Prepares a ascii string for writing fixes line endings Parameters
|
# | ||||||
public
|
write(string $data, string $mode = 'w', bool|string $force = false): boolean
Write given data to this File.
Write given data to this File. Parameters
ReturnsSuccess |
# | ||||||
public
|
append(string $data, bool|string $force = false): boolean
Append given data string to this File.
Append given data string to this File. Parameters
ReturnsSuccess |
# | ||||||
public
|
close(): boolean
Closes the current file if it is opened.
Closes the current file if it is opened. ReturnsTrue if closing was successful or file was already closed, otherwise false |
# | ||||||
public
|
delete(): boolean
Deletes the File.
Deletes the File. ReturnsSuccess |
# | ||||||
public
|
info(): string
Returns the File extension.
Returns the File extension. ReturnsThe File extension |
# | ||||||
public
|
ext(): string|false
Returns the File extension.
Returns the File extension. ReturnsThe File extension |
# | ||||||
public
|
name(): string|false
Returns the File name without extension.
Returns the File name without extension. ReturnsThe File name without extension. |
# | ||||||
public
|
safe(string $name = null, null|string $ext = null): string
makes filename safe for saving
makes filename safe for saving Parameters
Returns$ext the extension of the file |
# | ||||||
public
|
md5(mixed $maxsize = 5): string|false
Get md5 Checksum of file with previous check of Filesize
Get md5 Checksum of file with previous check of Filesize Parameters
Returnsmd5 Checksum {@link https://php.net/md5_file See md5_file()} |
# | ||||||
public
|
pwd(): string
Returns the full path of the File.
Returns the full path of the File. ReturnsFull path to file |
# | ||||||
public
|
exists(): boolean
Returns true if the File exists.
Returns true if the File exists. Returnstrue if it exists, false otherwise |
# | ||||||
public
|
perms(): string|false
Returns the "chmod" (permissions) of the File.
Returns the "chmod" (permissions) of the File. ReturnsPermissions for the file |
# | ||||||
public
|
size(): string|false|int
Returns the Filesize, either in bytes or in human-readable format.
Returns the Filesize, either in bytes or in human-readable format. Returnsfilesize as int or as a human-readable string |
# | ||||||
public
|
writable(): boolean
Returns true if the File is writable.
Returns true if the File is writable. Returnstrue if its writable, false otherwise |
# | ||||||
public
|
executable(): boolean
Returns true if the File is executable.
Returns true if the File is executable. Returnstrue if its executable, false otherwise |
# | ||||||
public
|
readable(): boolean
Returns true if the File is readable.
Returns true if the File is readable. Returnstrue if file is readable, false otherwise |
# | ||||||
public
|
owner(): integer|false
Returns the File's owner.
Returns the File's owner. Returnsthe Fileowner |
# | ||||||
public
|
group(): integer|false
Returns the File group.
Returns the File group. Returnsthe Filegroup |
# | ||||||
public
|
lastAccess(): integer|false
Returns last access time.
Returns last access time. Returnstimestamp Timestamp of last access time |
# | ||||||
public
|
lastChange(): integer|false
Returns last modified time.
Returns last modified time. Returnstimestamp Timestamp of last modification |
# | ||||||
public
&
|
folder(): Folder
Returns the current folder.
Returns the current folder. ReturnsCurrent folder |
# |
Properties | |||
---|---|---|---|
public
|
object
|
$folder
|
# |
public
|
string
|
$name
|
# |
public
|
string
|
$info = []
|
# |
public
|
resource
|
$handle
|
# |
public
|
boolean
|
$lock
|
# |