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 — Возвращает индексный дескриптор файла
filename
Путь к файлу.
Возвращает номер индексного дескриптора файла или false
, если возникла ошибка.
При сбое функция генерирует ошибку уровня E_WARNING
.
Пример #1 Сравнение индексного дескриптора файла с текущим файлом
<?php
$filename = 'index.php';
if (getmyinode() == fileinode($filename)) {
echo 'Вы проверяете текущий файл.';
}
?>
Замечание: Результаты функции кешируются. Подробнее о кешировании рассказывает описание функции 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.