Php counter program. 1) text counters? Php‑countfilecount.txt; set the file to save the data if (! File_exists ($ countfile) {determine whether the file exists exec (echo0 $ countfile);} $ fpfopen ($ countf 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
?>
Http://www.bkjia.com/PHPjc/315155.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/315155.htmlTechArticle1) text counters? Php $ countfile =/count.txt; // you can specify if (! File_exists ($ countfile) {// checks whether the file exists exec (echo 0 $ countfile);} $ fp = fopen ($ countf...