Autor Zpráva
Luc
Profil *
Zdravím =) Mám php kod (našla jsem ho na internetu, v php plavu, nesestavila bych ho sama) který počítá přístupy na stránku. Nevíte někdo jak to udělat aby to počítalo do stovky a pak to už nepočítalo?

<?php 
    $soubor = "pocet.txt"; 
    if( File_Exists($soubor) ){ 
      print ""; 
    }else{ 
      $file = fopen($soubor, "a"); 
      fputs($file, "0"); 
      fclose($file); 
    } 
    $file = fopen($soubor, "r+"); 
    $pocet = fgets($file, 100); 
    $pocet++; 
    fseek($file, 0); 
    fputs($file, $pocet); 
    fclose($file); 
    echo $pocet;
?>


Předem díky za odpověď =)
johnl
Profil
<?php 
    $soubor = "pocet.txt"; 
    if( File_Exists($soubor) ){ 
      print ""; 
    }else{ 
      $file = fopen($soubor, "a"); 
      fputs($file, "0"); 
      fclose($file); 
    } 
    $file = fopen($soubor, "r+"); 
    $pocet = fgets($file, 100); 
    $pocet++;
    if($pocet<=100){
    fseek($file, 0); 
    fputs($file, $pocet); 
    fclose($file); 
    }
    echo $pocet;
?>
A nebo jednodušeji..
<?php
if(file_exists("pocet.txt")){
$pocet = file_get_contents("pocet.txt");
if($pocet<=100){
file_put_contents("pocet.txt", $pocet+1);
}
echo $pocet+1;
?>
Luc
Profil *
je super děkuji moc =)

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0