PHP Function Reference

PHP diskfreespace() Function



The PHP diskfreespace() function returns the free space, in bytes, available on the specified filesystem or disk partition. This function is an alias of disk_free_space() function.

Note: This function does not work on remote files as the file to be examined must be accessible via the server's filesystem.

Syntax

diskfreespace(directory)

Parameters

directory Required. Specify a directory of the filesystem or disk partition.

Return Value

Returns the number of available bytes as a float or false on failure.

Example:

The example below shows the usage of diskfreespace() function.

<?php
//number of bytes available on "/"
echo diskfreespace("/")."\n";

//on Windows
echo diskfreespace("C:")."\n";
echo diskfreespace("D:")."\n";
?>

The output of the above code will be:

10376712192
15352312451
23289895439

❮ PHP Filesystem Reference