Flow PHP

SizeUnits

FinalYes

Constants

GiB_SIZE  = 1073741824
KiB_SIZE  = 1024
MiB_SIZE  = 1048576

Methods

gbToBytes()  : int
humanReadable()  : string
Format a byte count as a human-readable string (binary units: B, KiB, MiB, GiB, TiB, PiB).
kbToBytes()  : int
mbToBytes()  : int

Constants

Methods

gbToBytes()

public static gbToBytes(int $gb) : int
Parameters
$gb : int
Return values
int

humanReadable()

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
string

kbToBytes()

public static kbToBytes(int $kb) : int
Parameters
$kb : int
Return values
int

mbToBytes()

public static mbToBytes(int $mb) : int
Parameters
$mb : int
Return values
int

        
On this page

Search results