The Wayback Machine - https://web.archive.org/web/20240113005048/https://www.geeksforgeeks.org/php-disk_free_space-function/
Open In App
Related Articles

PHP disk_free_space( ) Function

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

The disk_free_space() function in PHP is an inbuilt function which is used to return the amount of free space in a specified directory. The disk_free_space() function denotes the free space in bytes.

It returns the available space on a filesystem or on a disk partition. The disk_free_space() function returns the number of bytes available on the corresponding filesystem or disk partition for a specified directory inputted as a string.

Syntax:

float disk_free_space ( $directory )

Parameters: The disk_free_space() function in PHP accepts one parameter which is $directory. This parameter specifies the directory which has to be checked.

Return Value: It returns the available space on a filesystem or on a disk partition.

Errors And Exception:

  1. The disk_free_space() function in PHP may give improper results if a file name is given as parameter instead of a directory.
  2. The disk_free_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_free_space("D:");
Output : 10969328844

Input : disk_free_space("C:");
Output : 10969327231

Below program illustrates the disk_free_space() function:

Program 1:




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


Output:

10969328844

Program 2:




<?php
  
// specifying directory to check for free space
echo disk_free_space("C:");
  
?>


Output:

10969327231

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

Learn to code easily with our course Coding for Everyone. This course is accessible and designed for everyone, even if you're new to coding. Start today and join millions on a journey to improve your skills!

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 26 Jun, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials