Visit the Official PHP Website |
PHP ProgrammingBy James N HitzTesting with stat()stat() is as easy to use as the other file testing functions but is not as straightforward. This is because it returns an array. The returned array has the following data: 0 device 1 inode 2 inode protection mode 3 number of links 4 user id of owner 5 group id owner 6 device type 7 size in bytes 8 time of last access 9 time of last modification 10 time of last change 11 blocksize for filesystem I/O 12 number of blocks allocated The items marked in red are NOT available on a Windows system. Other options like user id and group id are also not relevant on Windows 9x (this is a single-user OS. 'member?) This function is as you can see very comprehensive. It returns useful information about the specified files. I executed the following code fragment on a Windows system ... <?php $file2open = "./nt.txt"; $fileStat = stat($file2open); $totItems = sizeof($fileStat); $desc = array("device","inode","inode protection mode","number of links", "user id of owner","group id owner","device type","size in bytes", "last access","last modification","last change","blocksize", "number of blocks"); for($counter=0; $counter< $totItems; $counter++){ print "<p>$desc[$counter] is <b>$fileStat[$counter]"; } ?> ... and it produced the following output on my computer: device is 2
Notice items 6, 11 and 12 (counting from zero) are hereby set to -1. This is because they are not supported on the Windows system on which I executed the script. |
JamHitz Productions