June 21st, 2000, 06:04 PM
How does one write thread-safe code segments in PHP? Every counter (using a flat file) I've seen in PHP looks like this:
// read value from file
// increment value
// write value to file
Of course, if you have two clients getting this page, and one of them reads the value before the other writes, you'll have an inaccurate count.
So, generally how do you write thread-safe code in PHP. In JSP you have something like:
[code goes here]
Is their a similar construct in PHP, or do you have to roll your own?