This article describes how PHP uses text statistics to access the volume. Share to everyone for your reference, as follows:
Method 1:
$fp = fopen ("Counter.txt", "r+"), while (!flock ($FP, LOCK_EX)) {//acquire a exclusive LOCK //Waiting to LOCK the FIL e} $counter = Intval (Fread ($fp, FileSize ("Counter.txt")), $counter ++;ftruncate ($fp, 0); Truncate Filefwrite ($FP, $counter); Set your Datafflush ($FP); Flush output before releasing the Lockflock ($FP, lock_un); Release the Lockfclose ($FP);
Method 2:
counter.php file:
<?php/* counter *///opens countlog.txt to read the number of Hits$datei = fopen ("Countlog.txt", "R"); $count = Fgets ($dat ei,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);? >
Usage:
<?phpinclude ("counter.php");? >
More about PHP related content readers can view the topic: "PHP File Operation Summary", "PHP operation and operator Usage Summary", "PHP Network Programming Skills Summary", "PHP Basic Grammar Introductory Tutorial", "PHP operation Office Document tips summary (including word, excel,access,ppt), "PHP Date and Time usage summary", "PHP primer for Object-oriented programming", "PHP String Usage Summary", "Getting Started with Php+mysql database operations" and "PHP Common Database Operations Skills Summary"
I hope this article is helpful to you in PHP programming.
The above describes the PHP use of text statistics access to the method, including PHP, the content of the method, I hope that the PHP tutorial interested in a friend helpful.