4月 13 2015 Web►PHP [PHP] 瀏覽人數計算 雖然有用Google Analytics,但及時資料的API還在Beta中,所以還是索性寫了一個簡易的計算瀏覽人數的程式。 簡單來說就是計數器而已。 12345678910111213141516171819202122232425<?php $totalfile = fopen("total.txt", "r"); $total = fgets($totalfile); $total ++ ; fclose($totalfile); $totalfile = fopen("total.txt", "w"); fwrite($totalfile,$total) ; fclose($totalfile); $date = date("Y-m-d",filemtime("today.txt")) ; $todayfile = fopen("today.txt", "r"); if ( $date !== date ("Y-m-d")){ $today = 0 ; } else { $today = fgets($todayfile); } $today ++ ; fclose($todayfile); $todayfile = fopen("today.txt", "w"); fwrite($todayfile,$today) ; fclose($todayfile); echo $total ; echo $today ;?> Newer [Google Code Jam] 2015 - Qualification Round Older [Other] Byethost 寄放網域