A session-based graphic counter _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
A graph counter that uses sessions. This is a graph counter made of Sessions. after a user logs on, the counter is added. only when the browser is closed and re-opened will the counter be added. The counter written by SESSION, session_start (this is a graph counter made by SESSION. after a user logs on, the counter is incremented by one, and the counter is incremented only when the browser is closed and re-opened.
// Counter written with SESSION,
Session_start ();
If (session_is_registered (count) = false ){
While ($ fp = fopen ("counter.txt", "r +") = false );
While (flock ($ fp, 3) = false );
$ Count = fgets ($ fp, 255 );
$ Count + = 1;
Fseek ($ fp, 0 );
Fputs ($ fp, $ count );
Fclose ($ fp );
Session_register (count );
}

$ Len = strlen ($ count );
For ($ I = 1; $ I <= 6-$ len; $ I ++)
{
$ Imagpath = ""; // TEMP is the image folder. The image file name must be 0. GIF... 9.GIF.
}
For ($ I = 1; $ I <= $ len; $ I ++)
{
$ Imagpath. = "";
}

Print "you are the first". $ imagpath. "bits ";
?>

Bytes. // Counter written in SESSION, session_start (...

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.