Oihana PHP

getDiskUsage.php

Table of Contents

Functions

getDiskUsage()  : float
Returns the number of used bytes on the filesystem hosting a directory.

Functions

getDiskUsage()

Returns the number of used bytes on the filesystem hosting a directory.

getDiskUsage([string $directory = '.' ]) : float

Computed as getTotalDiskSpace()getFreeDiskSpace(), so the result shares the same unit (bytes) as the two helpers it builds on. Pair it with formatFileSize() for a human-readable value, or divide by getTotalDiskSpace() for a usage ratio.

Parameters
$directory : string = '.'

A directory (or path) on the filesystem to inspect (default: '.').

Tags
throws
FileException

If the disk space cannot be determined (e.g. invalid path).

author

Marc Alcaraz (ekameleon)

since
1.2.0
see
getFreeDiskSpace()
getTotalDiskSpace()
example
use function oihana\files\{ getDiskUsage , formatFileSize };

echo formatFileSize( (int) getDiskUsage( '/' ) ) ; // e.g. "187.4 GB"
Return values
float

The number of used bytes.

On this page

Search results