as an example of how to work with text files.
This webpage has been visited 265 times so far.
For a counter you need an additional file, a text file, let's call it "number.txt", which contains the number of visits so far. The PHP functions needed are
The function "fopen" generates a counter, which we name "$pointer" here, that points at the first character at the beginning. The modus could be "r" (read only), "r+" (read and write), "w" (write only), or "a" (append), for instance. The "fgets" function gives you the corresponding number of bytes, starting with your counter and moves the counter as many bytes to the back. "rewind($pointer)" puts the counter back to the beginning. "fputs($pointer,$counter)" writes the changed variable $counter on the position after the present $pointer position. It overwrites what was there before.
Erich Prisner, December 2003