FileSystem Function in PHP: PART 7

Introduction

In this article I describe the PHP FileSystem functions fileinode, filemtime, fileowner and fileperms. To learn some other FileSystem functions, go to:

  1. FileSystem Function in PHP: PART 1
  2. FileSystem Function in PHP: PART 2
  3. FileSystem Function in PHP: PART 3
  4. FileSystem Function in PHP: PART 4
  5. FileSystem Function in PHP: PART 5
  6. FileSystem Function in PHP: PART 6

PHP fileinode() Function

The PHP fileinode function is used to get the inode number of the specified file, in other words it returns the inode number of the file or false on failure.

Syntax

fileinode(filename)

Parameter in fileinode function

The parameter of the function is:

Parameter Description
filename It specifies the file to check.

Example

An example of the
function is:

<?
php
echo
fileinode("test.txt");
?>


Output

fileinode-function-in-php.gif

PHP filemtime() Function

The PHP filemtime function is used to get the file modification time. It returns the time that the file was last modified, or false on failure.

Syntax

filemtime(filename)

Parameter in filemtime function

The parameter of the function is:

Parameter Description
filename It specifies the file to check.

Example

An example of the
function is:

<?
php
$
time = time();
echo
"current date and times is ".date("m/d/y H:i:s ", $time);
echo
"<br>current File Modification Time is ".date("m/d/y H:i:s ", filemtime("test.txt"));
?>


Output

filemtime-function-in-php.gif

PHP fileowner() Function

The PHP fileowner function is used to get the owner id, in other words it returns the user id of the owner of the file or false on failure.

Syntax

filemtime(filename)

Parameter in fileowner function

The parameter of the function is:

Parameter Description
filename It specifies the file to check.

Example

An example of the
function is:

<?
php
echo
fileowner("test.txt");
?>


PHP fileperms() Function

The PHP fileperms function gets the file permission and retunes the file's permission as a numeric mode.

Syntax

filemtime(filename)

Parameter in fileperms function

The parameter of the function is:

Parameter Description
filename It specifies the file to check.

Example

An example of the
function is:

<?
php
$
time = time();
echo
"current date and times is ".date("m/d/y H:i:s ", $time);
echo
"<br>current File Modification Time is ".date("m/d/y H:i:s ", filemtime("test.txt"));
?>


Output

 fileperms-function-in-php.gif

Up Next
    Ebook Download
    View all
    Learn
    View all