disk_free_space()
disk_free_space() — Returns available space on filesystem or disk partition.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4 >= 4.1.0, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
Given a string containing a directory, this function will return the number of bytes available on the corresponding filesystem or disk partition.
Signature
disk_free_space(string $directory): float|false
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $directory | string | A directory of the filesystem or disk partition. |
Return value
Returns the number of available bytes as a float or false on failure.
Example
A runnable snippet:
// $df contains the number of bytes available on "/" $df = disk_free_space("/"); // On Windows: $df_c = disk_free_space("C:"); $df_d = disk_free_space("D:");
See also
All PHP 8.5 built-in functions
Reference card built from the PHP manual page disk_free_space() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.