Php counter program

Source: Internet
Author: User
1) Text Counter & lt ;? Php (as the mainstream development language) & #36; countfile/count.txt; & nbsp; // Set the file to save data if (! File_exists (& #36; countfile) & #123; // checks whether the file exists exec (echo0 & gt; & #36; countfile); & #125; 1) text counter
$ Countfile = "/count.txt"; // sets the file for saving data
If (! File_exists ($ countfile) {// checks whether the file exists.
Exec ("echo 0> $ countfile ");
}
$ Fp = fopen ($ countfile, "rw ");
$ Length = filesize ($ countfile );
$ Num = fgets ($ fp, $ length );
$ Num + = 1;
Exec ("rm-rf $ countfile ");
Exec ("echo $ num> $ countfile ");
Print "total visits:". "$ num". "times"; // display the number of visits
?>
2) graphic counters
$ Countfile = "/count-num.txt"; // sets the file for saving the data
If (! File_exists ($ countfile) // checks whether a file exists.
{Exec ("echo 0> $ countfile ");}
$ Fp = fopen ($ countfile, "rw ");
$ Length = filesize ($ countfile );
$ Num = fgets ($ fp, $ length );
$ Num + = 1;
Exec ("rm-rf $ countfile ");
Exec ("echo $ num> $ countfile ");
$ Len_str = strlen ($ num );
For ($ I = 0; $ I <$ len_str; $ I ++ ){
$ Each_num = substr ($ num, $ I, 1 );
$ Out_str = $ out_str ."";
}
Print "total visits:". "$ out_str". "times"; // display the number of visits
?>


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.