in reply to Reading and incrementing an integer

A couple things:
1. You're using a post-increment ($read_hits++), that increments the variable after it's written to the file.
2. Between the read and write in write_hits, you need to seek back to the beginning of the file to overwrite the previous value, rather than appending it to what was read.
  • Comment on Re: Reading and incrementing an integer