Return to Snippet

Revision: 1133
at September 14, 2006 20:21 by deadmoon


Updated Code
<?php 
//tutorial for text-file based counter
$counthandle=fopen("visits2.txt","r");
//opens file for reading and writing
$getcurrent=fread($counthandle,filesize("visits2.txt"));
//reads in current value
$getcurrent=$getcurrent+1;
//increment count by 1
fclose($counthandle);
$counthandle1=fopen("visits2.txt","w");
fputs($counthandle1,$getcurrent);
//input new value
fclose($counthandle1);
$counthandle2=fopen("visits2.txt","r");
$getrecent=fread($counthandle2,filesize("visits2.txt"));
//gets new value
//print "$getrecent";
//print counter value
fclose($counthandle2);
?>

Revision: 1132
at September 14, 2006 20:21 by deadmoon


Initial Code
//tutorial for text-file based counter
$counthandle=fopen("visits2.txt","r");
//opens file for reading and writing
$getcurrent=fread($counthandle,filesize("visits2.txt"));
//reads in current value
$getcurrent=$getcurrent+1;
//increment count by 1
fclose($counthandle);
$counthandle1=fopen("visits2.txt","w");
fputs($counthandle1,$getcurrent);
//input new value
fclose($counthandle1);
$counthandle2=fopen("visits2.txt","r");
$getrecent=fread($counthandle2,filesize("visits2.txt"));
//gets new value
//print "$getrecent";
//print counter value
fclose($counthandle2);

Initial URL
http://www.tutorialized.com/tutorial/Simple-Text-based-counter/374

Initial Description
http://www.tutorialized.com/tutorial/Simple-Text-based-counter/374

Initial Title
basic hit counter

Initial Tags


Initial Language
PHP