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!