PHP disk_total_space( ) Function Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The disk_total_space() function in PHP is an inbuilt function which is used to return the total space of a specified directory. The disk_total_space() function denotes the total space in bytes. It returns the total space on a filesystem or on a disk partition. The disk_total_space() function returns the total number of bytes on the corresponding filesystem or disk partition for a specified directory inputted as a string. Syntax: float disk_total_space ( string $directory ) Parameters: The disk_total_space() function in PHP accepts only one parameter $directory which is directory. Return Value: It returns the total space on a filesystem or on a disk partition. Errors And Exception: The disk_total_space() function in PHP may give improper results if a file name is given as parameter instead of a directory. The disk_total_space() function in PHP doesn't works for remote files.It only works on files which are accessible by the server's filesystem. Examples: Input : disk_total_space("D:"); Output : 10969328844798729 Input : disk_total_space("C:"); Output : 104379834795739795 Below programs illustrate the disk_total_space() function: Program 1: php <?php // specifying directory to check for total space echo disk_total_space("D:"); ?> Output: 10969328844798729 Program 2: php <?php // specifying directory to // check for total space $space = disk_total_space("C:"); echo "C: drive has a total capacity of $space bytes."; ?> Output: C: drive has a total capacity of 104379834795739795 bytes. Reference: https://www.php.net/manual/en/function.disk-total-space.php Comment More info S Shubrodeep Banerjee Follow Improve Article Tags : Misc Web Technologies PHP Explore PHP Tutorial 8 min read BasicsPHP Syntax 4 min read PHP Variables 5 min read PHP | Functions 8 min read PHP Loops 4 min read ArrayPHP Arrays 5 min read PHP Associative Arrays 4 min read Multidimensional arrays in PHP 5 min read Sorting Arrays in PHP 4 min read OOPs & InterfacesPHP Classes 2 min read PHP | Constructors and Destructors 5 min read PHP Access Modifiers 4 min read Multiple Inheritance in PHP 4 min read MySQL DatabasePHP | MySQL Database Introduction 4 min read PHP Database connection 2 min read PHP | MySQL ( Creating Database ) 3 min read PHP | MySQL ( Creating Table ) 3 min read PHP AdvancePHP Superglobals 6 min read PHP | Regular Expressions 12 min read PHP Form Handling 4 min read PHP File Handling 4 min read PHP | Uploading File 3 min read PHP Cookies 9 min read PHP | Sessions 7 min read Like