8.2、磁盘、目录和文件计算

 
 PHP Code By http://t.qq.com/tony-src
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
    
    /**
     * 确定文件的大小  filesize()
     */

    $file = 
'C:\appserv\www\HelloPHP\index.php' ;
    
echo round(filesize($file)/1024,2).'KB'.'<br>';

    
/**
     * 计算磁盘的可用空间        disk_free_space()
     */

    $driver = 
'C:';
    
echo round(disk_free_space($driver)/1024/1024/1024,2).'GB'.'<br>';
    
    
/**
     * 计算磁盘的总容量 disk_total_space()
     */

    
echo round(disk_total_space($driver)/1024/1024/1024,2).'GB'.'<br>';
    
    
/**
     * 确定文件的最后访问时间      fileatime(),最后访问时间
     */

    date_default_timezone_set(
'Asia/Shanghai');
    
echo date('Y-m-d H:i:s',fileatime($file)).'<br>';
    
    
/**
     * 确定文件的最后改变时间      filectime() ,所有者,权限修改时间
     */

    
echo date('Y-m-d H:i:s',filectime($file)).'<br>';
    
    
/**
     * 确定文件的最后修改时间      filemtime(),文件内容修改时间
     */

    
echo date('Y-m-d H:i:s',filemtime($file).'<br>');
    
?>




原文地址:https://www.cnblogs.com/tonycody/p/2799916.html