最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php使用文本統(tǒng)計(jì)訪問量的方法

 更新時(shí)間:2016年05月12日 11:24:10   作者:懶人  
這篇文章主要介紹了php使用文本統(tǒng)計(jì)訪問量的方法,涉及php文本文件讀寫與數(shù)值運(yùn)算的相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了php使用文本統(tǒng)計(jì)訪問量的方法。分享給大家供大家參考,具體如下:

方法1:

$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:

counter.php文件:

<?php
/* counter */
//opens countlog.txt to read the number of hits
$datei = fopen("countlog.txt","r");
$count = fgets($datei,1000);
fclose($datei);
$count=$count + 1 ;
echo "$count" ;
echo " hits" ;
echo "\n" ;
// opens countlog.txt to change new hit number
$datei = fopen("countlog.txt","w");
fwrite($datei, $count);
fclose($datei);
?>

用法:

<?php
include("counter.php");
?>

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《php文件操作總結(jié)》、《PHP運(yùn)算與運(yùn)算符用法總結(jié)》、《PHP網(wǎng)絡(luò)編程技巧總結(jié)》、《PHP基本語法入門教程》、《php操作office文檔技巧總結(jié)(包括word,excel,access,ppt)》、《php日期與時(shí)間用法總結(jié)》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總

希望本文所述對大家PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論

渝中区| 宝应县| 常山县| 永宁县| 兴业县| 邹城市| 乌兰浩特市| 霍林郭勒市| 阜宁县| 安化县| 静安区| 兴仁县| 大名县| 石河子市| 清丰县| 洱源县| 乡城县| 长治县| 安陆市| 安新县| 怀柔区| 江华| 巴林左旗| 洛宁县| 深圳市| 博野县| 甘泉县| 南部县| 阳谷县| 淮南市| 城固县| 修水县| 惠安县| 贡觉县| 岳阳市| 盘山县| 白水县| 临夏县| 兖州市| 井研县| 平舆县|