Download the PHP package chrisullyott/php-filesize without Composer
On this page you can find all versions of the php package chrisullyott/php-filesize. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download chrisullyott/php-filesize
More information about chrisullyott/php-filesize
Files in chrisullyott/php-filesize
Package php-filesize
Short Description Easily calculate file sizes and convert between units.
License MIT
Homepage https://github.com/chrisullyott/php-filesize
Informations about the package php-filesize
php-filesize
A flexible package for handling file sizes and converting between units.
Installation
Include in your project, or, install with Composer:
Instantiate
A FileSize
object, both on creation and within its methods, understands just about any expression of data size. You may instantiate it with a size, or leave it initially empty.
Convert between units
Use as()
to export the size in another format.
A variety of file size strings are supported here as well.
The second argument specifies decimal precision (default is 2
).
User-friendly formatting
Use asAuto()
to get a user-friendly string:
Optionally, asAuto()
also provides a decimal precision.
Or, simply echo
the object for the same functionality:
Modify the size
To make changes, use add()
, subtract()
, multiplyBy()
, and divideBy()
.
Negative values are supported. In the case below, 1.2 megabytes are subtracted:
You may also use add()
and subtract()
with an array of values:
Number base
The second argument of the constructor is the number base, which accepts either 2
(binary) or 10
(decimal). We use binary by default. To handle sizes in decimal:
Decimal separator
The third argument of the constructor is the decimal separator, which is a period .
by default. Here, you can use a comma instead. The chosen decimal separator will be used both to parse numbers properly, and also to format them on output.