Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Licznik, Co jakiś czas się zeruje
ziom
post
Post #1





Grupa: Zarejestrowani
Postów: 35
Pomógł: 0
Dołączył: 13.02.2005

Ostrzeżenie: (0%)
-----


Napisałem sobie dość prosty licznik na plikach, ale jest problem, bo co jakiś czas przeskakuje mi w dół. Nie jestem w stanie powiedzieć, czy do zera, ale raczej nie.

  1. <?
  2. class LICZNIK 
  3. { 
  4.  static private $odw; 
  5.  
  6.  static private $file; 
  7.  
  8.  public function __construct($var) 
  9.  { 
  10. self::$file = $var; 
  11. self::$odw = self::get(); 
  12.  
  13. setcookie('licznik',true,0); 
  14.  
  15. self::add(); 
  16.  } 
  17.  
  18.  public function odw() 
  19.  { 
  20. return self::$odw; 
  21.  } 
  22.  
  23.  private function add() 
  24.  { 
  25. if(!isset($_COOKIE['licznik'])) 
  26. { 
  27.  if(!file_exists(self::$file)) 
  28.  { 
  29. file_put_contents(self::$file, '1'); 
  30.  } 
  31.  else 
  32.  { 
  33. ++self::$odw; 
  34. file_put_contents(self::$file,self::$odw); 
  35.  } 
  36. } 
  37.  } 
  38.  
  39.  private function get() 
  40.  { 
  41. if(!file_exists(self::$file)) 
  42. { 
  43.  return '1'; 
  44.  file_put_contents(self::$file, '1'); 
  45. } 
  46. else 
  47. {
  48.  return file_get_contents(self::$file); 
  49. } 
  50.  } 
  51.  
  52. }
  53. ?>

Gdzie popełniłem błąd?

Ten post edytował ziom 26.05.2007, 11:11:53
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 14.09.2025 - 16:35