PHP: Get file attributes latest modification time:
- < ?php
- $file = 'test.txt';
- echo date('r',
filemtime($file));
- ?>
The unix timestamp is returned, which is commonly used in cache technology.
Related PHP file properties are also obtained by fileatime (), filectime () when the object's permissions, owner, metadata in all groups or other inode is updated, the fileowner () function returns the file owner.
$ Owner = posix_getpwuid (fileowner ($ file ));
(Non-window system), ileperms () Get file permissions,
- < ?php
- $file = 'dirlist.php';
- $perms = substr(sprintf
('%o', fileperms($file))
, -4);
- echo $perms;
- ?>
-
Filesize () returns the number of bytes of the file size:
- <? Php
- // The output is similar to: somefile.txt:
1024 bytes
- $ Filename = 'somefile.txt ';
- Echo $ filename .':'
. Filesize ($ filename). 'bytes ';
- ?>
-
PHP obtains all information about the file attributes. There is a function stat () that returns an array:
- < ?php
- $file = 'dirlist.php';
- $perms = stat($file);
- var_dump($perms);
- ?>
-