keep in mind that this function is prone to an overflow, and on big filesystems it will return negative values.
fileinode
(PHP 4, PHP 5)
fileinode — 取得文件的 inode
说明
int fileinode
( string
$filename
)取得文件的 inode。
参数
-
filename -
文件的路径。
返回值
返回文件的 inode 节点号, 或者在失败时返回 FALSE。
范例
Example #1 将某个文件和当前文件的 inode 进行对比
<?php
$filename = 'index.php';
if (getmyinode() == fileinode($filename)) {
echo 'You are checking the current file.';
}
?>
错误/异常
失败时抛出E_WARNING警告。
注释
Note: 此函数的结果会被缓存。参见 clearstatcache() 以获得更多细节。
Tip
自 PHP 5.0.0 起, 此函数也用于某些 URL 包装器。请参见 支持的协议和封装协议以获得支持 stat() 系列函数功能的包装器列表。
meltir at meltir dot com dot nothing ¶
5 years ago
mark nearby techexplained dot com ¶
8 years ago
This function, in spite of its name, also works for directories. Most any valid path in the filesystem will generate an inode value.
pixel20 at wp dot pl ¶
5 years ago
Sample function that generates apache 2.2 ETag. Useful for scripts serving images or other cachable data.
$file="example.png";
// Inode
$ETag = dechex(fileinode($file));
// Size
$ETag.= "-".dechex(filesize($file));
// Modification time in useconds & (2^33-1)
$ETag.= "-".dechex(((filemtime($file).str_repeat("0",6)+0) & (8589934591)));
header("ETag: \"$ETag\");
