In PHP, fileinode() returns the inode number of a file. An inode is the internal record that a Unix style file system uses to keep track of a file.
Every file on the disk has its own inode number. Two paths that point to the same inode are really the same file, which makes fileinode() useful for spotting hard links.
Syntax
Call fileinode() with the values you need. Start with this line.
PHP
$inode = fileinode('notes.txt');
Call
What it does
fileinode('notes.txt')
Returns the inode number of notes.txt, for example 2491873.
fileinode(__DIR__)
Works on folders too and returns the inode of the directory.
fileinode('missing.txt')
Returns false and raises a warning because the file does not exist.
On Windows, fileinode() does not give a useful number and often returns 0, because NTFS does not use inodes in the same way. Results are also cached, so call clearstatcache() if the file changes during the script.
Library declarations
PHP
fileinode(string $filename): int|false
Parameters
Parameter
Description
filename
Required. The path to the file or folder you want to check.
Return Value
Return Value
Description
int
Returns the inode number of the file on success.
false
Returns false on failure, for example when the file does not exist.