Posted By

deadmoon on 09/14/06


Tagged

basic txt hit counter


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vali29


basic hit counter


 / Published in: PHP
 

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

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

  1. <?php
  2. //tutorial for text-file based counter
  3. $counthandle=fopen("visits2.txt","r");
  4. //opens file for reading and writing
  5. $getcurrent=fread($counthandle,filesize("visits2.txt"));
  6. //reads in current value
  7. $getcurrent=$getcurrent+1;
  8. //increment count by 1
  9. fclose($counthandle);
  10. $counthandle1=fopen("visits2.txt","w");
  11. fputs($counthandle1,$getcurrent);
  12. //input new value
  13. fclose($counthandle1);
  14. $counthandle2=fopen("visits2.txt","r");
  15. $getrecent=fread($counthandle2,filesize("visits2.txt"));
  16. //gets new value
  17. //print "$getrecent";
  18. //print counter value
  19. fclose($counthandle2);
  20. ?>

Report this snippet  

You need to login to post a comment.