Php method of using Text statistics Access amount PHP Timing method php Encapsulation method PHP system licensor

Source: Internet
Author: User
Tags getting started with php php programming
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.