[Solved] Count visitors to website with php


You are truncating counterfile.txt every time you open it:

w+: Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.

Source: the php manual

Please note that you probably want to flock() your handle to prevent race conditions. (LOCK_EX = Exclusive Lock, LOCK_SH = Shared Lock)

solved Count visitors to website with php