Three php counter codes. Three php counter codes are added to the article. All three of them share the same common point, that is, they do not need a database, but use text files to view and Count Web pages on instances. Three articles are added to the favorites. three php counter codes are added to the favorites. All three of them share the same vertices, that is, they do not need databases. Instead, they use text files to view and Count Web pages on instances.
Three php Tutorial counter codes are added to the article. The three of them share the same common point, that is, they do not need database tutorials, but use text files to view and Count Web pages on instances.
// Counter
Function countx ($ file = "count. dat "){
If (file_exists ($ file )){
$ Fp = fopen ($ file, "r ");
$ Numx = fgets ($ fp, 10 );
Fclose ($ fp );
$ Numx ++;
// The above four lines of code can be replaced by an expression: $ numx = file_get_contents ($ file) + 1;
}
Else {
$ Numx = 1 ;}
File_put_contents ($ file, $ numx); // when the file does not exist, this function automatically creates the file and converts the parameter to a string for writing.
Echo $ numx;
/* The entire function body can be replaced by two expressions: file_exists ($ file )? File_put_contents ($ file, file_get_contents ($ file) + 1): file_put_contents ($ file, "1"); readfile ($ file );
*/
}
// Function call
Countx ();
?>
Code 2
$ Counterfile = "balong.txt"; // number of file names for storing numeric values
Function displaycounter ($ counterfile ){
$ Fp = fopen ($ counterfile, "rw ");
$ Num = fgets ($ fp, 5 );
$ Num + = 1;
Print "you are the". "$ num". "guy reading the barrier counter ";
Exec ("rm-rf $ counterfile ");
Exec ("echo $ num> $ counterfile ");
}
If (! File_exists ($ counterfile )){
Exec ("echo 0> $ counterfile ");
}
Displaycounter ($ counterfile );
?>
Code 3
$ Counterfile = "www.bkjia.com.txt"; // number of file names for storing numeric values
Function displaycounter ($ counterfile ){
$ Fp = fopen ($ counterfile, "rw ");
$ Num = fgets ($ fp, 5 );
$ Num + = 1;
Print "you are the". "$ num". "guy reading the barrier counter ";
Exec ("rm-rf $ counterfile ");
Exec ("echo $ num> $ counterfile ");
}
If (! File_exists ($ counterfile )){
Exec ("echo 0> $ counterfile ");
}
Displaycounter ($ counterfile );
?>
Bytes. Three articles are added to your favorites...