PHP教程.應用實例3

PHP計數器
<?php
$counterFile = "balong.txt";//存儲數值的文件名幾路徑
function displayCounter($counterFile) {
$fp = fopen($counterFile,"rw");
$num = fgets($fp,5);
$num += 1;
print "您是第 "."$num"." 個看巴瀧計數器的傢夥";
exec( "rm -rf $counterFile");
exec( "echo $num > $counterFile");
}
if (!file_exists($counterFile)) {
exec( "echo 0 > $counterFile");
}
displayCounter($counterFile);
?>

You May Also Like