SizeUnits
FinalYes
Constants
Methods
- gbToBytes() : positive-int
- humanReadable() : string
- Format a byte count as a human-readable string (binary units: B, KiB, MiB, GiB, TiB, PiB).
- kbToBytes() : positive-int
- mbToBytes() : positive-int
Constants
GiB_SIZE
public
int
GiB_SIZE
= 1073741824
KiB_SIZE
public
int
KiB_SIZE
= 1024
MiB_SIZE
public
int
MiB_SIZE
= 1048576
Methods
gbToBytes()
public
static gbToBytes(positive-int $gb) : positive-int
Parameters
- $gb : positive-int
Return values
positive-inthumanReadable()
Format a byte count as a human-readable string (binary units: B, KiB, MiB, GiB, TiB, PiB).
public
static humanReadable(null|int $bytes[, int $decimals = 2 ][, string $decimalSeparator = '.' ][, string $thousandsSeparator = ',' ][, string $null = '-' ]) : string
The tail arguments mirror PHP's number_format signature for the fractional part.
Parameters
- $bytes : null|int
-
size in bytes, or null for "unknown" (returns $null)
- $decimals : int = 2
-
Number of fractional digits for non-byte units. Ignored for raw bytes.
- $decimalSeparator : string = '.'
-
decimal separator (passed to number_format)
- $thousandsSeparator : string = ','
-
thousands separator for the integer part (passed to number_format)
- $null : string = '-'
-
placeholder returned when $bytes is null
Return values
stringkbToBytes()
public
static kbToBytes(positive-int $kb) : positive-int
Parameters
- $kb : positive-int
Return values
positive-intmbToBytes()
public
static mbToBytes(positive-int $mb) : positive-int
Parameters
- $mb : positive-int