Possible Duplicate:
File resource persistence in PHP
If using fopen
for opening a file, it will be closed and unset at the end of the PHP script even without fclose
.
$fp = fopen('data.txt', 'w');
fwrite($fp, 'text');
fclose($fp);
Now if it is a frequently used script, we need to open/close the file with the filesystem too many times (file I/O). It would be better to keep the file open. This is the technique that database systems use.
Is there a function in PHP to leave a file open and do not re-open it on the next run?
Or How we can setup a semi-server to keep a file opened for frequent access by PHP?