Open In App

PHP fileinode() Function

Last Updated : 28 Mar, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The fileinode() function is an inbuilt function in PHP that returns the inode of the file.

Syntax:

fileinode(string $filename): int|false

Parameter: This function has only one parameter:

  • filename: This parameter specifies the path for the particular file.

Return Value: This function returns the inode number of the file otherwise returns “false”.

Error: Depending upon the failure, an E_WARNING will be emitted.

Example 1: The following code demonstrates the fileinode() function.

PHP




<?php
  
$filename = "index.php";
  
if (getmyinode() == fileinode($filename)) {
    echo "You are checking the current file.";
}
  
?>


Output:

You are checking the current file.

Example 2: The following code is another demonstration of the fileinode() function.

PHP




<?php
  
$filename = "text.txt";
  
if (getmyinode() == fileinode($filename)) {
    echo "You are checking the current file.";
} else {
    echo "You are not checking the current files";
}
  
?>


Output:

You are not checking the current files 

Reference: https://www.php.net/manual/en/function.fileinode.php


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads