Folder::size()

Gets the total sizes of files contained in the folder in human readable string format.

Table of Contents
  1. Description
  2. Example

Description

Folder::size(?string $unit = null, int $fix = 2, int $base = 1000): ?string;

This method returns the total sizes of files contained in the folder as a string of a number followed by a unit. If the folder does not exist, this method returns null.

Example

$folder = new Folder('.\path\to\folder');

$size = $folder->size(); // Returns `'11.63 MB'` (automatic, as short as possible)
$size = $folder->size('KB'); // Returns `'11633.36 KB'` (force unit to KB)
$size = $folder->size(base: 1024); // Returns `'11.09 MiB'` (automatic, as short as possible using base of 1024)
$size = $folder->size(base: 1024, unit: 'KiB'); // Returns `'11360.73 KiB'` (force unit to KiB)

Folder::size()

Gets the total sizes of files contained in the folder in human readable string format.