Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php

What is the disk_free_space() function in PHP?

Muhammad Ashir

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

PHP provides a number of built-in functions for handling and manipulating file systems. The disk_free_space() function returns the size of the disk partition or file directory that is free. It returns the size in bytes.

Syntax

disk_free_space(string $directory): float|false

Parameters

  • directory: A directory of the file system or disk partition.

Note: If a file name is provided instead of a directory or file system, then the working of disk_free_space() is unspecified and may vary from OS to OS or different PHP versions.

Return values

disk_free_space() returns the size in the number of bytes upon success and returns false upon failure.

Code

<?php
// $df contains the number of bytes available on "/"
$df = disk_free_space("./");
print("Free space (bytes) $df")
?>

The code above prints the free space in the current directory that is given by the / symbol.

RELATED TAGS

php

CONTRIBUTOR

Muhammad Ashir
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring