note 22960 deleted from function.fwrite by philip

From: Date: Sat, 19 Oct 2002 17:35:10 +0000
Subject: note 22960 deleted from function.fwrite by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-38299@lists.php.net to get a copy of this message
My personal attempt at using PHP to build a page counter using file access ops, rather than a database. I hope this useful to someone else...very very very basic and no exception checking! # # Builds a basic page counter using a text file! # # Filename $cnt_file = "count.txt"; # Read single line into a string $string = implode("", file($cnt_file)); # Print the value echo $string; # Add one to current value $string++; # Open file for write, no append! $tmpfile = fopen($cnt_file,"w"); # Write the new value back to the string $fp = fwrite($tmpfile,$string); # Close file fclose($tmpfile);

« previous php.notes (#38299) next »