Re[2]: [PHP] php file writting ?
| From: | Tom Rogers | Date: | Sat, 15 Mar 2003 02:55:04 +0000 |
| Subject: | Re[2]: [PHP] php file writting ? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-139776@lists.php.net to get a copy of this message | ||
Hi,
Saturday, March 15, 2003, 4:53:44 AM, you wrote:
RP> Yes I did.
RP> Here is the code, maybe I am just missing something (this is the part
RP> where it writes and then opens again...
RP> $h6 = fopen("/etc/group.backup","a");
RP> for($i = 0; $i < count($users); $i++)
RP> {
RP> for($k = 0; $k < count($grouplines);$k++)
RP> {
RP> $groupline = explode(":", $grouplines[$k]);
RP> if($groupline[0] == $users[$i])
RP> continue 2;
RP> }
RP> $line = $users[$i] . ":x:" . ($user_ids[$i]+1000) .
RP> ":\n";
RP> fwrite($h6, $line);
RP> }
RP> fclose($h6);
RP> //have to re read the group file since we just modified it
RP> $h7 = fopen("/etc/group.backup","r");
RP> $groupcontent = fread($h7,filesize("/etc/group.backup"));
RP> fclose($h7);
RP> If I output the filesize("/etc/group.backup") after h6 is closed it is 0
RP> even though it is not.
RP> Ron
RP> On Fri, 2003-03-14 at 12:15, Chris Hayes wrote:
>> At 18:53 14-3-2003, you wrote:
>> >I open a file, modify it, save it out to disk. The VERY next line, i
>> >open it, and the size is zero. I look at the file and it is fine (not
>> >zero).
>> >
>> >I think there is a timing issue with php on file read/writes. I tried
>> >sleep(1), but all that did was slow the script down (didn't help).
>> >
>> un-educated guess:
>> did you try fclose then fopen again?
>>
>>
You could try clearstatcache() after the fclose.
Although the fopen,close is not listed in the affected files you never know...
--
regards,
Tom