J'ai un soucis avec un fichier "fantome"
le code suivant génère un fichier text et incrémente une valeur
Code : Tout sélectionner
<?php
$minih=1;
$maxih=6;
$calculh=rand($minih,$maxih);
$calculh=$calculh+6;
$habilite="habilite.txt";
touch($habilite);
$fp = @fopen($habilite, "r");
if (!$fp)
{
echo "Impossible d'ouvrir $habilite en lecture";
exit;
}
$comptehabilite = fgets($fp, 3);
$comptehabilite=$comptehabilite+$calculh;
fclose($fp);
$fp = @fopen($habilite, "w"); // le fichier est ouvert en ecriture, remis a zero
if (!$fp) {
echo "Impossible d'ouvrir $habilite en ecriture";
exit;
}
fputs($fp, $comptehabilite);
fclose($fp);
?>
Il ne porte pas d'extension, contient et se nomme comme le résultat du rand()+6.
Si quelqu'un a une