1. Home
  2. Computing & Technology
  3. PHP / MySQL

PHP Flat File Counter

By Angela Bradley, About.com

3 of 4

Updating the Text File With The New Count

fseek($handle, 0) ;
//Puts the pointer back to the begining of the file

fwrite($handle, $count) ;
//saves the new count to the file

fclose($handle) ;
//closes the file

?>
This code starts by returning the pointer to the start of our file. If we don't do this, we'll just be tacking numbers onto the end of our current number, and not actually overwriting the count. Once we are at the start of the file, we use fwrite () to overwrite the old count with the new one, so it is ready for the next visitor.
Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Step By Steps
  5. PHP Counter Text Pad - PHP Flat File Counter - PHP No Database Counter

©2009 About.com, a part of The New York Times Company.

All rights reserved.