首页 > 代码库 > php基础26:文件与目录1

php基础26:文件与目录1

<meta charset="utf-8">
<?php
    
    //绝对路径
    $path = "E:\AppServ\www\php\/33-catalog.php";
    echo basename($path);
    echo "<hr>";
    echo "<pre>";
    print_r(pathinfo($path));
    echo "</pre>";
    echo "<hr>";

    //相对路径
    $path2 = "33-catalog.php";
    echo realpath($path2);
    echo "<hr>";

    //磁盘,目录,文件大小
    $filename = "33-catalog.php";
    echo $filename.":".filesize($filename)."Byte";
    echo "<br/>";
    echo $filename.":".round((filesize($filename)/1024),2)."kb";
    echo "<hr>";

    //计算磁盘的可用空间
    echo round(disk_free_space("C:")/1024/1024/1024,2)."G";
    echo "<br>";

    //计算磁盘总空间大小
    echo round(disk_total_space("C:")/1024/1024/1024,2)."G";
    echo "<br>";
    echo "<hr>";

    //设置默认时区
    date_default_timezone_set("Asia/Shanghai");

    //获取最后访问时间
    $path="E:\AppServ\www\php\/01-dataType.php";
    echo "获取最后访问时间".date("Y-m-d H:i:s",fileatime($path));

    //获取最后改变时间
    echo "<br>";
    echo "权限所有者".date("Y-m-d H:i:s",filectime($path));

    //获取最后的修改时间
    echo "<br>";
    echo "获取最后的修改时间".date("Y-m-d H:i:s",filemtime($path));
?>

 

php基础26:文件与目录1