O olmasaydı dosyasını yaratacak file_get_contents için herhangi bir alternatif var mı. Ben temelde bir tek satır komut için arıyorum. Ben bir program için indirme istatistikleri saymak için kullanıyorum. Ben pre-indirme sayfasında bu PHP kodu kullanabilirsiniz:
Download #: <?php $hits = file_get_contents("downloads.txt"); echo $hits; ?>
ve daha sonra indirme sayfasında, ben bu var.
<?php
function countdownload($filename) {
if (file_exists($filename)) {
$count = file_get_contents($filename);
$handle = fopen($filename, "w") or die("can't open file");
$count = $count + 1;
} else {
$handle = fopen($filename, "w") or die("can't open file");
$count = 0;
}
fwrite($handle, $count);
fclose($handle);
}
$DownloadName = 'SRO.exe';
$Version = '1';
$NameVersion = $DownloadName . $Version;
$Cookie = isset($_COOKIE[str_replace('.', '_', $NameVersion)]);
if (!$Cookie) {
countdownload("unqiue_downloads.txt");
countdownload("unique_total_downloads.txt");
} else {
countdownload("downloads.txt");
countdownload("total_download.txt");
}
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$DownloadName.'" />';
?>
Doğal olarak da, kullanıcı ilk ön-yükleme sayfasına eriştiğinde, bu yüzden onun henüz oluşturulmuş değil. Ben sade ve basit olmak istiyorum ve değişen / ekleme değil bir sürü ön indirme sayfasına herhangi fonksiyonlar eklemek istemiyorum.
Edit:
Böyle bir şey işe, ama onun benim için çalışmıyor mu?
$count = (file_exists($filename))? file_get_contents($filename) : 0; echo $count;