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

PHP disk_free_space() function and disk_total_space() function description

怪我咯
Release: 2023-03-13 13:04:01
Original
1609 people have browsed it

disk_free_space — Returns the free space in the directory

Description

 disk_free_space ( $directory )
Copy after login

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:" );
?>
Copy after login

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 )
Copy after login

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:" );
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template