International PHP Conference Munich 2025

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() - ファイルに関する情報を取得する

add a note

User Contributed Notes 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