PHP完全自学手册(珍藏版) 中文pdf扫描版下载
- $fp = fopen("counter.txt", "r+");
- while(!flock($fp, LOCK_EX)) { // acquire an exclusive lock
- // waiting to lock the file
- }
- $counter = intval(fread($fp, filesize("counter.txt")));
- $counter++;
- ftruncate($fp, 0); // truncate file
- fwrite($fp, $counter); // set your data
- fflush($fp); // flush output before releasing the lock
- flock($fp, LOCK_UN); // release the lock
- fclose($fp);
转载请注明:谷谷点程序 » php利用统计访问量的简单实现方法