Php file for online count statistics

Source: Internet
Author: User
If you don't want to use session to solve the online number of people statistics, you can use the php file to perform operations. In fact, the implementation is still a little complicated, so I have commented in detail on the following code, leave a message if you do not understand it! & Amp; lt ;? Phpecho & quot; php point

If you don't want to use session to solve the online number of people statistics, you can use the php file to perform operations. In fact, the implementation is still a little complicated, so I have commented in detail on the following code, leave a message if you do not understand it!


 Time () {array_push ($ temp, $ user [0]. ",". $ user [1]); $ user_arr = implode ("#", $ temp) ;}// save the user information array_push ($ temp, getenv ("REMOTE_ADDR "). ",". (time () + $ timeout ). "#"); $ user_arr = implode ("#", $ temp); $ fp = fopen ($ online_log, "w"); // update the file flock ($ fp, LOCK_EX); // lock the file handle @ fputs ($ fp, $ user_arr); flock ($ fp, LOCK_UN); // release lock @ fclose (); echo "current number of online users ". count ($ temp);?>

After running, count.txt is as follows:

Wagner. 0.0.1, 1343299774 #

In the next php Tutorial, I will use session to count the number of online users!

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.