note 22023 added to function.fread

From: Date: Tue, 04 Jun 2002 08:35:04 +0000
Subject: note 22023 added to function.fread
Groups: php.notes 
Request: Send a blank email to php-notes+get-31410@lists.php.net to get a copy of this message
WARNING : HAZY ERROR DUE TO FILESYSTEM ! THIS CODE : // get contents of a file into a string $filename = "/usr/local/something.txt"; $fd = fopen ($filename, "r"); $contents = fread ($fd, filesize ($filename)); fclose ($fd); GOT AN ERROR. (under linux v2.2.4) I explain: I did a change in the file's length, by ADDING some characters, then CLOSED the file, used this code to GET the whole file in another function, an the filesize was still the OLD filesize (without the extra characters). So I got the whole file BEFORE I added the characters. I worked it around with filesize()+1024 but this isn't a proper solution. This hazy error may occur for some other filesystem than the ext2 of linux 2.2.4. Be careful !!! -- http://www.php.net/manual/en/function.fread.php http://master.php.net/manage/user-notes.php?action=edit+22023 http://master.php.net/manage/user-notes.php?action=delete+22023 http://master.php.net/manage/user-notes.php?action=reject+22023

« previous php.notes (#31410) next »