当前位置: 首页 > 网络学院 > 服务端脚本教程 > PHP > stat() 函数

PHP
PHP Libxml
PHP Math
PHP Misc
PHP MySQL
PHP SimpleXML
PHP String
PHP XML
PHP Zip
PHP Mail
用PHP5的DirectoryIterators递归扫描目录
PHP 阻止SQL注入式攻击
PHP5面向对象 - 基础 - 类和对象
PHP5面向对象 - 基础 - 类的属性( public )
PHP5面向对象 - 基础 - 类的属性( private )
PHP5面向对象 - 基础 - 方法
PHP5面向对象 - 基础 - 对象的比较
php5面向对象 - 基础 - 构造函数
php5面向对象 - 基础 - 析构函数
用PHP控制用户的浏览器 - ob*函数的使用
PHP PDO 学习笔记

PHP 中的 stat() 函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 484 ::
收藏到网摘: n/a

Definition and Usage
定义和用法

The stat() function returns information about a file.
stat()函数的作用是:返回一个文件的信息。

This function returns an array with the following elements:
这个函数将返回一个包含下列元素的数组:

  • [0] or [dev] - Device number
    [0] 或 [dev] –代表(驱动)设备的数字
  • [1] or [ino] - Inode number
    [1] 或 [ino] – 代表Inode的数字
  • [2] or [mode] - Inode protection mode
    [2] 或 [mode] – Inode保护模式
  • [3] or [nlink] - Number of links
    [3] 或 [nlink] –代表连接的数字
  • [4] or [uid] - User ID of owner
    [4] 或 [uid] – 拥有者的用户id[User ID]
  • [5] or [gid] - Group ID of owner
    [5] 或 [gid] – 拥有者的群id[Group ID]
  • [6] or [rdev] - Inode device type
    [6] 或 [rdev] – Inode设备类型
  • [7] or [size] - Size in bytes
    [7] 或 [size] – 字节数大小
  • [8] or [atime] - Last access (as Unix timestamp)
    [8] 或 [atime] – 最后一次访问(Unix时间戳[timestamp])
  • [9] or [mtime] - Last modified (as Unix timestamp)
    [9] 或 [mtime] -最后一次修改(Unix时间戳[timestamp])
  • [10] or [ctime] - Last inode change (as Unix timestamp)
    [10] 或 [ctime] -最后一次修改inode(Unix时间戳[timestamp])
  • [11] or [blksize] - Blocksize of filesystem IO (if supported)
    [11] 或 [blksize] – 文件系统IO的区域大小[Blocksize of filesystem IO](必须在支持这个元素的情况下)
  • [12] or [blocks] - Number of blocks allocated
    [12] 或 [blocks] – 指派的空间数量

Syntax
语法

stat(file)

Parameter
参数
Description
描述
file Required. Specifies the file to check
必要参数。指定文件对


Tips and Notes
提示和注意点

Note: The results from this function will differ from server to server. The array may contain the number index, the name index, or both.
注意:从这个函数返回的结果与“服务器到服务器[server to server]”的结果是不相同的。这个数组包含了数字索引、名称索引或同时包含上述二者。

Note: The result of this function are cached. Use clearstatcache() to clear the cache.
注意:这个函数的结果将被自动缓存。你可以使用clearstatcache()函数来清除这个缓存。

Tip: This function is similar to fstat(), except that with this function the file does not have to be open.
提示:stat()函数与fstat()大致类似。唯一的不同点就是:stat() 函数返回的文件对象不需要事先打开。


Example
案例

<?php
$file = fopen("test.txt","r");
print_r(stat($file));
fclose($file);
?> 

The output of the code above could be:
上述代码将输出下面的结果:

Array
(
[0] => 0
[1] => 0
[2] => 33206
[3] => 1
[4] => 0
[5] => 0
[6] => 0
[7] => 92
[8] => 1141633430
[9] => 1141298003
[10] => 1138609592
[11] => -1
[12] => -1
[dev] => 0
[ino] => 0
[mode] => 33206
[nlink] => 1
[uid] => 0
[gid] => 0
[rdev] => 0
[size] => 92
[atime] => 1141633430
[mtime] => 1141298003
[ctime] => 1138609592
[blksize] => -1
[blocks] => -1
)

评论 (0) All

登陆 | 还没注册?