File
in package
Com\Tecnick\File\File
Function to read byte-level data
Tags
Table of Contents
Methods
- fileGetContents() : string
- Reads entire file into a string.
- fopenLocal() : resource
- Wrapper to use fopen only with local files
- fReadInt() : int
- Read a 4-byte (32 bit) integer from file.
- getAltFilePaths() : array<string|int, string>
- Returns an array of possible alternative file paths or URLs
- getFileData() : string|false
- Reads entire file into a string.
- getUrlData() : string|false
- Reads entire remote file into a string using CURL
- rfRead() : string
- Binary-safe file read.
Methods
fileGetContents()
Reads entire file into a string.
public fileGetContents(string $file)
: string
The file can be also an URL.
Parameters
- $file : string
-
Name of the file or URL to read.
Return values
stringfopenLocal()
Wrapper to use fopen only with local files
public fopenLocal(string $filename,
string $mode)
: resource
Parameters
- $filename : string
-
Name of the file to open
- $mode : string
-
The fopen mode parameter specifies the type of access you require to the stream
Tags
Return values
resource —Returns a file pointer resource on success
fReadInt()
Read a 4-byte (32 bit) integer from file.
public fReadInt(resource $resource)
: int
Parameters
- $resource : resource
-
A file system pointer resource that is typically created using fopen().
Return values
int —4-byte integer
getAltFilePaths()
Returns an array of possible alternative file paths or URLs
public getAltFilePaths(string $file)
: array<string|int,
string>
Parameters
- $file : string
-
Name of the file or URL to read.
Return values
array<string|int, string> —List of possible alternative file paths or URLs.
getFileData()
Reads entire file into a string.
public getFileData(string $file)
: string|false
The file can be also an URL if the URL wrappers are enabled.
Parameters
- $file : string
-
Name of the file or URL to read.
Return values
string|false —File content or FALSE in case the file is unreadable
getUrlData()
Reads entire remote file into a string using CURL
public getUrlData(string $url)
: string|false
Parameters
- $url : string
-
URL to read.
Tags
Return values
string|falserfRead()
Binary-safe file read.
public rfRead(resource|null $resource,
int<0,
max> $length)
: string
Reads up to length bytes from the file pointer referenced by handle. Reading stops as soon as one of the following conditions is met: length bytes have been read; EOF (end of file) is reached.
Parameters
- $resource : resource|null
-
A file system pointer resource that is typically created using fopen().
- $length : int<0, max>
-
Number of bytes to read.