fileinode

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

fileinode取得文件的 inode

说明

fileinode(string $filename): int|false

取得文件的 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() 系列函数功能的包装器列表。

参见

  • getmyinode() - 获取当前脚本的索引节点(inode)
  • stat() - 给出文件的信息

添加备注

用户贡献的备注 2 notes

up
0
crrodriguez at opensuse dot org
10 months ago
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.
up
0
sofe2038 at gmail dot com
4 years ago
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.
To Top