1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
<?
function compteur()
{
$fichiercompteur = "compteur.txt";
if (file_exists($fichiercompteur))
{
$fp = fopen($fichiercompteur, "r+");
$compteur = fgets($fp,6);
$compteur++;
rewind($fp);
fwrite($fp,$compteur,6);
fclose($fp);
}
else
{
$fp = fopen($fichiercompteur, "w");
$compteur = "1";
fwrite($fp,$compteur,6);
fclose($fp);
}
return $compteur;
}
?>
<html>
<head>
</head>
<body>
<h1>Compteur</h1>
<? echo compteur() ?>
<p>
<a href="<? echo $PHP_SELF ?>">Démarrer le script permettant d'augmenter le compteur</a>
</body>
</html> |
Partager