Usage of stat function in php
❮ PHP Filesystem Reference Show ExampleGet information about a file: $stat = stat("test.txt"); Run Example » Definition and UsageThe stat() function returns information about a file. Note: The results from this function will differ from server to server. The array may contain the number index, the name index, or both. Note: The result of this function is cached. Use clearstatcache() to clear the cache. SyntaxParameter Values
Technical Details
❮ PHP Filesystem Reference (PHP 4, PHP 5, PHP 7, PHP 8) stat — Gives information about a file Descriptionstat(string lstat() is identical to stat() except it would instead be based off the symlinks status. Parametersfilename Path to the file. Return Valuesstat() and fstat() result format
* On Windows this will always be ** Only valid on systems supporting the st_blksize type - other systems (e.g. Windows) return *** On Windows, as of PHP 7.4.0, this is the serial number of the volume that contains the file, which is a 64-bit unsigned integer, so may overflow. Previously, it was the numeric representation of the drive letter (e.g. **** On Windows, as of PHP 7.4.0, this is the identifier associated with the file, which is a 64-bit unsigned integer, so may overflow. Previously, it was always ***** On Windows, the writable permission bit is set according to the read-only file attribute, and the same value is reported for all users, group and owner. The ACL is not taken into account, contrary to is_writable(). The value of mode file types
So for example a regular file could be In case of error, stat() returns
Errors/Exceptions Upon failure, an Changelog
ExamplesExample #1 stat() example
Example #2 Using stat() information together with touch()
Notes
Tip As of PHP 5.0.0, this function can also be used with some URL wrappers. Refer to Supported Protocols and Wrappers to determine which wrappers support stat() family of functionality. See Also
webmaster at askapache dot com ¶ 8 years ago
if ( $ver ) {
webmaster at askapache dot com ¶ 13 years ago
admin at smitelli dot com ¶ 16 years ago
mao at nospam dot com ¶ 17 years ago
= ssh2_connect($host, 22);
salisbm at hotmail dot com ¶ 19 years ago
ian at eiloart dot com ¶ 23 years ago
digitalaudiorock at hotmail dot com ¶ 13 years ago
mail4rico at gmail dot com ¶ 14 years ago
com dot gmail at algofoogle ¶ 17 years ago
marting.dc AT gmail.com ¶ 16 years ago
$file = readdir($handle)) {
JulieC ¶ 15 years ago
svend at svendtofte dot com ¶ 17 years ago
Hellhound ¶ 14 years ago
carlos [at] encore-lab [dot] com ¶ 7 years ago
Anonymous ¶ 16 years ago
= filemtime($file); antonixyz at gmx dot net ¶ 14 years ago
Anonymous ¶ 17 years ago
What does stat function returns?The stat() function gets status information about a specified file and places it in the area of memory pointed to by the buf argument. If the named file is a symbolic link, stat() resolves the symbolic link. It also returns information about the resulting file.
What function gives information about a file PHP?The stat() function returns information about a file.
What give information about block size of file system IO in PHP?Note: Because PHP's integer type is signed and many platforms use 32bit integers, some filesystem functions may return unexpected results for files which are larger than 2GB.
...
Return Values ¶. |