PHP stat() 函数

PHP 教程 · 2019-01-25 15:56:23

定义和用法

stat() 函数返回关于文件的信息。

该函数将返回一个包含下列元素的数组:

  • [0] 或 [dev] - 设备编号
  • [1] 或 [ino] - inode 编号
  • [2] 或 [mode] - inode 保护模式
  • [3] 或 [nlink] - 连接数目
  • [4] 或 [uid] - 所有者的用户 ID
  • [5] 或 [gid] - 所有者的组 ID
  • [6] 或 [rdev] - inode 设备类型
  • [7] 或 [size] - 文件大小的字节数
  • [8] 或 [atime] - 上次访问时间(Unix 时间戳)
  • [9] 或 [mtime] - 上次修改时间(Unix 时间戳)
  • [10] 或 [ctime] - 上次 inode 改变时间(Unix 时间戳)
  • [11] 或 [blksize] - 文件系统 IO 的块大小(如果支持)
  • [12] 或 [blocks] - 所占据块的数目

语法


stat(filename)


参数 描述
filename 必需。规定文件的路径。

提示和注释

注释:从这个函数返回的结果与服务器到服务器的结果是不相同的。这个数组包含了数字索引、名称索引或同时包含上述二者。

注释:该函数的结果会被缓存。请使用 clearstatcache() 来清除缓存。

实例


<?php
$stat = stat('test.txt');
echo 'Acces time: ' .$stat['atime'];
echo '<br />Modification time: ' .$stat['mtime'];
echo '<br />Device number: ' .$stat['dev'];
?> 

上面的代码将输出:


Access time: 1141633430
Modification time: 1141298003
Device number: 0


点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html

查看所有标签

The Sovereign Individual

The Sovereign Individual

James Dale Davidson、William Rees-Mogg / Free Press / 1999-08-26 / USD 16.00

Two renowned investment advisors and authors of the bestseller The Great Reckoning bring to light both currents of disaster and the potential for prosperity and renewal in the face of radical changes ......一起来看看 《The Sovereign Individual》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

随机密码生成器
随机密码生成器

多种字符组合密码

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具