Jump to: navigation, search

Php stat

From w3cyberlearnings

Contents

PHP function stat

This function gives information related to a file. Information such as access time, modify time, and much more. Please see the information.

Syntax stat

name of a file (is a real file, not a symbolic link file).

stat(file);

Note

Result of this function can be unexpected when the file is larger than 2GB and because PHP's integer type for some platforms uses 32bit integers.

Return

Failure returns E_WARNING is emitted.

Return Format

Index   Associate Description
------------------------------------------------------------
0	dev	device number
1	ino	inode number *
2	mode	inode protection mode
3	nlink	number of links
4	uid	userid of owner *
5	gid	groupid of owner *
6	rdev	device type, if inode device
7	size	size in bytes
8	atime	time of last access (Unix timestamp)
9	mtime	time of last modification (Unix timestamp)
10	ctime	time of last inode change (Unix timestamp)
11	blksize	blocksize of filesystem IO **
12	blocks	number of 512-byte blocks allocated **

Example 1

<?php
$fileinfor = stat('index.php');

foreach ($fileinfor as $k => $v) {
    echo $k . ': ' . $v;
    echo "<br/>";
}
?>

Output

0: 2049
1: 2120957
2: 33188
3: 1
4: 1000
5: 1000
6: 0
7: 6993
8: 1336426746
9: 1333461460
10: 1335778276
11: 4096
12: 16
dev: 2049
ino: 2120957
mode: 33188
nlink: 1
uid: 1000
gid: 1000
rdev: 0
size: 6993
atime: 1336426746
mtime: 1333461460
ctime: 1335778276
blksize: 4096
blocks: 16

Related Links


basename-- chgrp-- chmod-- chown-- clearstatcache-- copy-- delete-- dirname-- disk_free_space-- disk_total_space-- diskfreespace-- fclose-- feof-- fflush-- fgetc-- fgetcsv-- fgets-- fgetss-- file_exists-- file_get_contents-- file_put_contents- file-- fileatime-- filectime-- filegroup-- fileinode-- filemtime-- fileowner-- fileperms-- filesize-- filetype-- flock-- fnmatch-- fopen-- fpassthru-- fputcsv-- fputs-- fread-- fscanf-- fseek-- fstat-- ftell-- ftruncate-- fwrite-- glob-- is_dir-- is_executable-- is_file-- is_link-- is_readable-- is_uploaded_file-- is_writable-- is_writeable-- lchgrp-- lchown-- link-- linkinfo-- lstat-- mkdir-- move_uploaded_file-- parse_ini_file-- parse_ini_string-- pathinfo-- pclose-- popen-- readfile-- readlink-- realpath_cache_get-- realpath_cache_size-- realpath-- rename-- rewind-- rmdir-- set_file_buffer-- stat-- symlink-- tempnam-- tmpfile-- touch-- umask-- unlink--

Navigation
Web
SQL
MISC
References