本文实例讲述了PHP使用文本统计访问量的方法。分享给大家供大家参考,具体如下:
方法1:
rush:PHP;">
$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);
方法2:
rush:PHP;">
用法:
rush:PHP;">
更多关于PHP相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》、《》、《》、《》及《》
希望本文所述对大家PHP程序设计有所帮助。
原文地址:https://www.jb51.cc/php/19794.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。