On the linux kernel, COW filesystems like BTRFS, BcacheFS, etc Inode numbers are not usable to determine if something is the same file.
This is intentional.
(PHP 4, PHP 5, PHP 7, PHP 8)
fileinode — 取得文件的 inode
filename
文件的路径。
返回文件的 inode 节点号, 或者在失败时返回 false
。
失败时抛出 E_WARNING
警告。
示例 #1 将某个文件和当前文件的 inode 进行对比
<?php
$filename = 'index.php';
if (getmyinode() == fileinode($filename)) {
echo 'You are checking the current file.';
}
?>
注意: 此函数的结果会被缓存。参见 clearstatcache() 以获得更多细节。
自 PHP 5.0.0 起, 此函数也用于某些 URL 包装器。请参见 支持的协议和封装协议以获得支持 stat() 系列函数功能的包装器列表。
On the linux kernel, COW filesystems like BTRFS, BcacheFS, etc Inode numbers are not usable to determine if something is the same file.
This is intentional.
As documented in https://www.php.net/manual/en/function.stat.php#refsect1-function.stat-returnvalues:
> On Windows, as of PHP 7.4.0, this is the identifier associated with the file, which is a 64-bit unsigned integer, so may overflow. Previously, it was always 0.
It appears that fileinode shares the same underlying implementation.