Home  >  Article  >  Backend Development  >  PHP disk_free_space() function and disk_total_space() function description

PHP disk_free_space() function and disk_total_space() function description

怪我咯
怪我咯Original
2017-07-11 09:18:371552browse

disk_free_space — Returns the free space in the directory

Description

 disk_free_space ( $directory )

Gives a string containing a directory , this function will return the number of available bytes based on the corresponding file system or disk partition.

Parameters directory

File system directory or disk partition.

Note:

If a file name is specified instead of a file directory, the behavior of this function will not be uniform and will vary depending on the operating system and PHP version.

Return value

Returns the number of available bytes in floating point, or FALSE on failure.

disk_free_space() Example

<?php
// $df 包含根目录下可用的字节数
$df  =  disk_free_space ( "/" );

//在 Windows 下:
$df_c  =  disk_free_space ( "C:" );
$df_d  =  disk_free_space ( "D:" );
?>

Note: This function cannot be used on remote files. The file being checked must be accessible through the server's file system.

disk_total_space — Returns the total disk size of a directory

Description

disk_total_space ( $directory )

gives a character containing a directory String, this function will return all bytes according to the corresponding file system or disk partition. [Translator's Note] This function returns the total size of the disk partition where the directory is located, so the results obtained by giving different directories of the same disk partition as parameters are exactly the same. Mounting a disk partition as a subdirectory is supported in both Unix and Windows 200x/XP, in which case it makes sense to use this function correctly.

Parameters

directory The directory or disk partition of the file system.

Return value

Returns the total disk size of a directory in bytes in floating point, or FALSE on failure.

disk_total_space() Example

<?php
// $df 包含 "/" 目录的磁盘大小
$ds  =  disk_total_space ( "/" );

//在 Windows 下:
$ds  =  disk_total_space ( "C:" );
$ds  =  disk_total_space ( "D:" );
?>

Note: This function cannot be used on remote files. The files being checked must be accessible through the server's file system.

The above is the detailed content of PHP disk_free_space() function and disk_total_space() function description. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn