stat
Gives information about a file.
stat Function synopsis
stat(string $filename): array|false
Parameters
$filename
Typestring
Path to the file.
Return value
Typearray|false
-
On Windows this will always be
0.** Only valid on systems supporting the st_blksize type - other systems (e.g. Windows) return
-1.* 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.
2forC:) forstat, and0forlstat.** 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
0.***** 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
modecontains information read by several functions. When written in octal, starting from the right, the first three digits are returned bychmod. The next digit is ignored by PHP. The next two digits indicate the file type:So for example a regular file could be
0100644and a directory could be0040755.In case of error,
statreturnsfalse.
Changes to the stat Function
PHP 8.0
- Return type added:
array|false - Parameter type added for parameter #1 (
$filename):string
- stat($filename)
+ stat(string $filename): array|false stat Function Availability
stat Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |