PHP中的lstat()函數用於返回有關文件或符號鏈接的信息。它收集文件的統計信息,該統計信息作為參數發送到lstat()函數。該函數返回一個數組,其中包含有關以下元素的信息:
- [0]或[dev]-設備號
- [1]或[ino]-索引節點編號
- [2]或[mode]-索引節點保護模式
- [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]-分配的塊數
注意:
This function is similar to stat(), except that if the file parameter is a symbolic link, the status of the symlink is return not the status of the file pointed to by the symlink.
用法:
lstat(file)
使用的參數:
PHP中的lstat()函數接受一個參數。
- file:它是指定文件的必需參數。
返回值:
它返回一個包含上述元素的數組。
異常:
- lstat()函數的結果因服務器而異。
- 此函數的結果被緩存,因此使用clearstatcache()函數清除緩存。
- 失敗時發出E_WARNING。
範例:1
Input:print_r(lstat("gfg.txt")); Output: 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 )
示例:2
Input:symlink('gfg.php', 'gfg'); array_diff(stat('gfg'), lstat('gfg')); Output: Array ( [ino] => 97236376 [mode] => 33188 [size] => 34 [atime] => 1223580003 [mtime] => 1223581848 [ctime] => 1223581848 [blocks] => 8 ) Explanation:Difference of the resluts of stat() and lstat() function
以下示例程序旨在說明lstat()函數。
程序1:
<?php
// displaying information using lstat() function
print_r(lstat("gfg.txt"));
?>
輸出:
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 )
程序2:
<?php
// creating a symbolic link
symlink('gfg.php', 'gfg');
// comparing information returned
// by stat() and lstat() function
array_diff(stat('gfg'), lstat('gfg'));
?>
輸出:
Array ( [ino] => 97236376 [mode] => 33188 [size] => 34 [atime] => 1223580003 [mtime] => 1223581848 [ctime] => 1223581848 [blocks] => 8 )
程序3:
<?php
// displaying information of
// zip file using lstat() function
$myfile = lstat("./gfg.zip");
echo($myfile);
?>
輸出:
Array ( [0] => 2161 [1] => 18351063 [2] => 33188 [3] => 1 [4] => 1036 [5] => 1036 [6] => 0 [7] => 270081 [8] => 1382409024 [9] => 1382409631 [10] => 1382409631 [11] => 4096 [12] => 528 [dev] => 2161 [ino] => 18351063 [mode] => 33188 [nlink] => 1 [uid] => 1036 [gid] => 1036 [rdev] => 0 [size] => 270081 [atime] => 1382409024 [mtime] => 1382409631 [ctime] => 1382409631 [blksize] => 4096 [blocks] => 528 )
相關文章: PHP - stat( )用法及代碼示例
參考:
http://php.net/manual/en/function.lstat.php
相關用法
- PHP Ds\Map xor()用法及代碼示例
- p5.js box()用法及代碼示例
- PHP Ds\Set get()用法及代碼示例
- p5.js min()用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- p5.js hue()用法及代碼示例
- PHP pow( )用法及代碼示例
- PHP next()用法及代碼示例
- p5.js sin()用法及代碼示例
- PHP each()用法及代碼示例
- d3.js d3.mean()用法及代碼示例
- d3.js d3.max()用法及代碼示例
注:本文由純淨天空篩選整理自Shubrodeep Banerjee大神的英文原創作品 PHP | lstat() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。