stat

(PHP 3, PHP 4 , PHP 5)

stat -- ファイルに関する情報を取得する

説明

array stat ( string filename)

filenameで指定されたファイルに ついての統計情報を取得します。 filenameがシンボリックリンクの場合、 シンボリックリンクではなくファイルの実体の統計情報が返されます。 lstat()はシンボリックリンクの統計情報を返すという違いを除いて stat()と等価です。

stat()はエラーの場合 FALSE を返し、かつwarningを発行します。

ファイルの統計情報を、以下の要素を持つ配列として返します。 ゼロベース(添え字は数値)の配列に加えて、 各パラメータ毎の連想配列としてもアクセスできます。 これはPHP4.0.6以上で使用できます。

表 1. stat()fstat()の 結果のフォーマット

NumericAssociative (since PHP 4.0.6)説明
0devdevice number
1inoinode number
2modeinode protection mode
3nlinknumber of links
4uiduserid of owner
5gidgroupid of owner
6rdevdevice type, if inode device *
7sizesize in bytes
8atimetime of last access (unix timestamp)
9mtimetime of last modification (unix timestamp)
10ctimetime of last change (unix timestamp)
11blksizeblocksize of filesystem IO *
12blocksnumber of blocks allocated
* - st_blksizeタイプをサポートするシステムでのみ有効です。 その他のシステム(例えばWindows)では -1 を返します。

注意: この関数の結果は キャッシュされます。詳細は、clearstatcache() を参照 して下さい。

注意: この関数では、 リモートファイルを 使用することはできません。これは、処理されるファイルがサーバーの ファイルシステムによりアクセスできる必要があるためです。

lstat(), fstat(), filemtime(), filegroup()も参照してください。