SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
-
Jun 21, 2001, 10:27 #1
I need an expert to check this code
Hello,
I have some very important files that I have to update regularly. I used to do this in PERL but now I want to switch to PHP. I've created the following piece of code to open, lock, read, write and then close a file all at once. The code is as follows:
PHP Code:$filename = "veryimportantfile.irs";
$file = fopen($filename, "r+");
flock($file,2);
$text = fread ($file, filesize ($filename));
.....edit the input here.........
rewind($file);
ftruncate($file,0);
fwrite($file, $text);
fclose($file);
Please take a look and tell me what you think.
P.S. I don't want to read the file and then open it for writing, it MUST be done all at once. Can't explain any further but this is a must.
-
Jun 21, 2001, 12:09 #2
- Join Date
- Jun 2001
- Location
- Georgia
- Posts
- 102
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Secrecy is the fuel for sceptical ppl...
--Odd
"We all live in a yellow subroutine."
"Some call it insanity; I call it inspiration!"
Bookmarks