PHP latency is read long enough to ensure writing

How do I delay a PHP script that writes to a text file and then reads from the same file long enough to make sure the changes have been written before I try to read?

+2


a source to share


3 answers


@symcbean is correct. You need to close the handle you are working on first using fclose. Then open the read connection. The way PHP works is that it will not move to the next line until the previous line has completed operations. So if you are interested in reading after writing, make sure it is in code. This differs from java and javaScript, where triggers call code snippets to run.



0


a source


Just flush the file write buffer and then you should be good to go:



http://us.php.net/manual/en/function.fflush.php

0


a source


You should learn how to use flock (lock file for writing, reading).

0


a source







All Articles