PHP | disk_total_space( ) Function

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:

  1. The disk_total_space() function in PHP may give improper results if a file name is given as parameter instead of a directory.
  2. 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:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// specifying directory to check for total space
echo disk_total_space("D:");
  
?>

chevron_right


Output:

10969328844798729

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// specifying directory to
// check for total space
$space = disk_total_space("C:");
  
echo "C: drive has a total capacity
                    of $space bytes.";
  
?>

chevron_right


Output:

C: drive has a total capacity of 104379834795739795 bytes.

Reference:
http://php.net/manual/en/function.disk-total-space.php



My Personal Notes arrow_drop_up

I am a technology enthusiast who has a keen interest in programming I am pursuing Engineering in Computer Science from GEU, Dehradun I like to unwind by watching movies and English sitcomsI have a keen interest in music

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.