downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

ftell> <fseek
Last updated: Wed, 22 Jul 2009

view this page in

fstat

(PHP 4, PHP 5)

fstat — Verzameld de statestieken van een bestand geopend door de bestandspointer

Beschrijving

array fstat ( resource $handle )

Verzameld de statestieken van een bestand geopend door de bestandspointer handle . Deze functie is gelijkend aan de stat() functie, behalve dat hij werkt met een open bestands pointer in plaats van een bestandsnaam.

Geeft een array met statestieken over het bestand; het formaat van de array staat in detail beschreven in de handleiding van stat().

Example#1 fstat() example

<?php

// opent een bestand
$fp fopen("/etc/passwd""r");

// haalt statestieken op
$fstat fstat($fp);

// sluit het bestand
fclose($fp);

// laat alleen het relevante gedeelte zien
print_r(array_slice($fstat13));

?>

Dit geeft als resultaat:

Array
(
    [dev] => 771
    [ino] => 488704
    [mode] => 33188
    [nlink] => 1
    [uid] => 0
    [gid] => 0
    [rdev] => 0
    [size] => 1114
    [atime] => 1061067181
    [mtime] => 1056136526
    [ctime] => 1056136526
    [blksize] => 4096
    [blocks] => 8
)

Note: The results of this function are cached. See clearstatcache() for more details.

Note: This function will not work on remote files as the file to be examined must be accessible via the servers filesystem.



add a note add a note User Contributed Notes
fstat
broom at alturnanetworks dot com
03-Oct-2008 12:21
Another ftp_get_contents() approach, using a temperary stream handler. Returns file contents of remote file as string.

<?php
function ftp_get_contents ($conn_id, $remote_filename) {
   
//Create temp handler:
   
$tempHandle = fopen('php://temp', 'r+');

   
//Get file from FTP assuming that it exists:
   
ftp_fget($conn_id, $tempHandle, $remote_filename, FTP_ASCII, 0));

   
//Getting detailed stats to check filesize:
   
$fstats = fstat($tempHandle);

    return
fread($tempHandle, $fstats['size']);
}
?>

(It is recommended to add some error handling)
sheran at comtrust dot co dot ae
22-Feb-2001 02:14
On Windows NT the typical array element names for the fstat function are:

dev
ino
mode
nlink
uid
gid
size
atime
mtime
ctime

ftell> <fseek
Last updated: Wed, 22 Jul 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites