男女疯狂一边摸一边做羞羞视频|啊好深好硬快点用力别停动态图|亚洲一区无码中文字幕|特级无码毛片免费视频播放▽|久久狠狠躁免费观看|国内精品久久久久久网站

stat

(PHP 4, PHP 5, PHP 7, PHP 8)

stat給出文件的信息

說(shuō)明

stat(string $filename): array

獲取由 filename 指定的文件的統計信息。如果 filename 是符號連接,則統計信息是關(guān)于被連接文件本身的,而不是符號連接。

lstat()stat() 相同,只除了它會(huì )返回符號連接的狀態(tài)。

參數

filename

文件的路徑。

返回值

stat()fstat() 返回格式
數字下標 關(guān)聯(lián)鍵名(自 PHP 4.0.6) 說(shuō)明
0 dev device number - 設備名
1 ino inode number - inode 號碼
2 mode inode protection mode - inode 保護模式
3 nlink number of links - 被連接數目
4 uid userid of owner - 所有者的用戶(hù) id
5 gid groupid of owner- 所有者的組 id
6 rdev device type, if inode device * - 設備類(lèi)型,如果是 inode 設備的話(huà)
7 size size in bytes - 文件大小的字節數
8 atime time of last access (unix timestamp) - 上次訪(fǎng)問(wèn)時(shí)間(Unix 時(shí)間戳)
9 mtime time of last modification (unix timestamp) - 上次修改時(shí)間(Unix 時(shí)間戳)
10 ctime time of last change (unix timestamp) - 上次改變時(shí)間(Unix 時(shí)間戳)
11 blksize blocksize of filesystem IO * - 文件系統 IO 的塊大小
12 blocks number of blocks allocated - 所占據塊的數目
* Windows 下總是 0。

* - 僅在支持 st_blksize 類(lèi)型的系統下有效。其它系統(如 Windows)返回 -1。

如果出錯,stat() 返回 false。

注意: 因為 PHP 的整數類(lèi)型是有符號整型而且很多平臺使用 32 位整型,對 2GB 以上的文件,一些文件系統函數可能返回無(wú)法預期的結果。

錯誤/異常

錯誤時(shí)會(huì )產(chǎn)生 E_WARNING 級別的錯誤。

更新日志

版本 說(shuō)明
4.0.6 返回一個(gè)數組包含有文件的統計信息,該數組具有以下列出的單元,數組下標從零開(kāi)始。除了數字索引之外自還可以通過(guò)關(guān)聯(lián)索引來(lái)訪(fǎng)問(wèn)。

范例

示例 #1 stat() 例子

<?php
/* Get file stat */
$stat stat('C:\php\php.exe');

/*
 * Print file access time, this is the same 
 * as calling fileatime()
 */
echo 'Access time: ' $stat['atime'];

/*
 * Print file modification time, this is the 
 * same as calling filemtime()
 */
echo 'Modification time: ' $stat['mtime'];

/* Print the device number */
echo 'Device number: ' $stat['dev'];
?>

示例 #2 Using stat() information together with touch()

<?php
/* Get file stat */
$stat stat('C:\php\php.exe');

/* Did we failed to get stat information? */
if (!$stat) {
    echo 
'stat() call failed...';
} else {
    
/*
     * We want the access time to be 1 week 
     * after the current access time.
     */
    
$atime $stat['atime'] + 604800;

    
/* Touch the file */
    
if (!touch('some_file.txt'time(), $atime)) {
        echo 
'Failed to touch file...';
    } else {
        echo 
'touch() returned success...';
    }
}
?>

注釋

注意:

注意:不同文件系統對時(shí)間的判斷方法可能是不相同的。

注意: 此函數的結果會(huì )被緩存。參見(jiàn) clearstatcache() 以獲得更多細節。

小技巧

自 PHP 5.0.0 起, 此函數也用于某些 URL 包裝器。請參見(jiàn) 支持的協(xié)議和封裝協(xié)議以獲得支持 stat() 系列函數功能的包裝器列表。

參見(jiàn)

  • lstat() - 給出一個(gè)文件或符號連接的信息
  • fstat() - 通過(guò)已打開(kāi)的文件指針取得文件信息
  • filemtime() - 取得文件修改時(shí)間
  • filegroup() - 取得文件的組

男女疯狂一边摸一边做羞羞视频|啊好深好硬快点用力别停动态图|亚洲一区无码中文字幕|特级无码毛片免费视频播放▽|久久狠狠躁免费观看|国内精品久久久久久网站