Home >Backend Development >PHP Tutorial >How to use php disk_free_space() function?

How to use php disk_free_space() function?

怪我咯
怪我咯Original
2017-07-11 09:19:141526browse

disk_free_space() 函数返回目录中的可用空间

语法

disk_free_space(directory)

参数   directory    必需。规定要检查的目录。    

directory 参数是一个目录的字符串。该函数将根据相应的文件系统或磁盘分区返回可用的字节数。

实例

 获取指定目录下的所有可用空间,返回整形数据,单位是字节,下面是演示disk_free_space函数使用方法的实例.

   <?PHP
     $SdiskSpace=round(disk_free_space("c:\\")/1024/1024/1024,2);
     echo($diskSpace,"GB") 
   ?>

   程序中调用disk_free _space()函数,获取C:\目录的可用空间(即C盘的可用空间),返回的数据单位是字节,所以程序将其3次降以1024,将数据单位转换为GB,调用round()函数可以对得到的数据进行四舍五入,只保留小数点后两位.

The above is the detailed content of How to use php disk_free_space() function?. 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