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 changes have been written before I attempt the read?
Ah - that's perfect! Thanks :-)
safetycopy
2010-05-20 05:44:45
If you need to do that then there's something **very** broken in your operating system or PHP. Or you're opening a second file handle on the file (without closing the first) instead of using the original handle or a duplicate. Which means your code is broken.This is *NOT* how to fix the issue.
symcbean
2010-05-20 10:59:56
OK, if that's not the right way, what would you recommend?
safetycopy
2010-05-20 23:59:43
symcbean, it's possible in scenarios where one is using the `w+` or `a+` options.
Amber
2010-05-21 00:30:55
A:
@symcbean is correct. You need to first close the handle you are working on using fclose. Then open up the read connection. The way PHP works is that it won't move to the next line until the previous line has completed operations. So if you are concerned with the read running after the write, then make sure that is where it is in the code. This is different from java and javaScript where triggers cause pieces of the code to run.
Joseph
2010-05-20 14:25:52