PHP Class Horde_View_Helper_Number, horde

Author: Mike Naberezny ([email protected])
Author: Derek DeVries ([email protected])
Author: Chuck Hagenbuch ([email protected])
Inheritance: extends Horde_View_Helper_Base
ファイルを表示 Open project: horde/horde

Public Methods

Method Description
numberToHumanSize ( integer | float $size, $precision = 1 ) : string Formats the bytes in $size into a more understandable representation.

Method Details

numberToHumanSize() public method

Useful for reporting file sizes to users. This method returns NULL if $size cannot be converted into a number. You can change the default precision of 1 in $precision.
$this->numberToHumanSize(123)           => 123 Bytes
$this->numberToHumanSize(1234)          => 1.2 KB
$this->numberToHumanSize(12345)         => 12.1 KB
$this->numberToHumanSize(1234567)       => 1.2 MB
$this->numberToHumanSize(1234567890)    => 1.1 GB
$this->numberToHumanSize(1234567890123) => 1.1 TB
$this->numberToHumanSize(1234567, 2)    => 1.18 MB
public numberToHumanSize ( integer | float $size, $precision = 1 ) : string
$size integer | float Size to format.
return string Formatted size value.