Contador simple de visitas - Webeame Snippets


Añadir snippet

Contador simple de visitas

  1. function load_counter() {
  2. if (file_exists('counter.txt')){
  3. $n = file_get_contents('counter.txt');
  4. return intval($n);
  5. }
  6. return 0;
  7. }
  8.  
  9. function update_counter($i=1) {
  10.  
  11. $n = load_counter();
  12. $n += $i;
  13.  
  14. $fp = fopen('counter.txt', "w+");
  15. fwrite($fp, $n);
  16. fclose($fp);
  17.  
  18. return $n;
  19. }
Uso
  1. // count the current visit and output the count
  2. $visits = update_counter();
  3.  
  4. // just load the counter data
  5. $visits = load_counter();

En PHP contador visitas por admin hace on 30/1/08 | Comentarios

Comentarios

Logeate para comentar