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

查看所有标签

Designing with Web Standards (2nd Edition)

Designing with Web Standards (2nd Edition)

Jeffrey Zeldman / Peachpit Press / 2006-07-06 / USD 44.99

Best-selling author, designer, and web standards evangelist Jeffrey Zeldman has updated his classic, industry-shaking guidebook. This new edition--now in full color--covers improvements in best prac......一起来看看 《Designing with Web Standards (2nd Edition)》 这本书的介绍吧!

MD5 加密
MD5 加密

MD5 加密工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具