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

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

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

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

方法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基本語(yǔ)法入門教程》、《php操作office文檔技巧總結(jié)(包括word,excel,access,ppt)》、《php日期與時(shí)間用法總結(jié)》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫(kù)操作入門教程》及《php常見數(shù)據(jù)庫(kù)操作技巧匯總

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

相關(guān)文章

最新評(píng)論

房山区| 贵阳市| 同江市| 宁津县| 宁德市| 黑龙江省| 邢台市| 始兴县| 鹤庆县| 汕头市| 海门市| 延长县| 宜春市| 潍坊市| 海盐县| 阿拉善左旗| 马山县| 灯塔市| 凯里市| 建阳市| 连南| 赣州市| 吉林市| 乌什县| 乌拉特中旗| 米易县| 万宁市| 宜城市| 苏尼特右旗| 夏河县| 文昌市| 赣榆县| 托克托县| 湘阴县| 无为县| 玉环县| 深水埗区| 林周县| 汝阳县| 巴南区| 阿尔山市|