<?php
$counter = 'www.mywebsite.com/counter/counter.txt';
$download = 'www.mywebsite.com/file/1.pdf';
$number = file_get_contents($counter); // read count file
$number++; // increment count by 1
$fh = fopen($counter, 'w'); // open count file for writing
fwrite($fh, $number); // write new count to count file
fclose($fh); // close count file
header("Location: $download"); // get download
?>
为什么数字计数器在ex:5,999之后重启5000?而不是6,000 ???
答案 0 :(得分:0)
<?php
$counter = 'www.mywebsite.com/counter/counter.txt';
$download = 'www.mywebsite.com/file/1.pdf';
$number = intval(file_get_contents($counter)); // read count file
$number++; // increment count by 1
$fh = fopen($counter, 'w'); // open count file for writing
fwrite($fh, $number); // write new count to count file
fclose($fh); // close count file
header("Location: $download"); // get download
&GT;
!!! intval()...已修复。