PHP code example of landall / filesize
1. Go to this page and download the library: Download landall/filesize library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
landall / filesize example snippets
use L1nnah\FileSize\FileSizeConverter;
use L1nnah\FileSize\FileSizeUnits;
$valueInBytes = 123456;
$converter = new FileSizeConverter($valueInBytes);
$readable = $converter->convertTo(FileSizeUnits::KB);
echo $readable->toFixed(2); // Expected: "120.56 KB"
use L1nnah\FileSize\FileSizeConverter;
$converter = FileSizeConverter::fromString("1.234,56 MB");
echo $converter->sizeInBytes; // Expected: "1294467072"
bash
vendor/bin/phpunit tests/FileSizeTest.php
vendor/bin/phpunit tests/FileSizeFromStringTest.php