Simple counter. Simple counters? * | A simple counter * functionget_hitcount ($ counter_file) {* returns the counter to zero. if the counter is not used, the initial value is 1. you can also use a simple counter. /*
| A simple counter
*/
Function get_hitcount ($ counter_file)
{
/* Returns the counter to zero.
In this case, if the counter is not used, the initial value is 1.
Of course, you can set the initial value to 20000 to cheat me.
*/
$ Count = 0;
// If the stored counter file already exists, read the content
If (file_exists ($ counter_file ))
{
$ Fp = fopen ($ counter_file, "r ");
// We only took the first 20 digits. I hope your site will not be too popular.
$ Count = intval (fgets ($ fp, 20 ));
// Because the function fgets () returns a string, we can automatically convert it to an integer by adding 0.
Fclose ($ fp );
// File operation completed
}
// Increase the count value once
$ Count;
// Write the new count value to the file
$ Fp = fopen ($ counter_file, "w ");
Fputs ($ fp, $ count );
Fclose ($ fp );
# Return count value
Return ($ count );
}
?>
Why? /* | A simple counter */function get_hitcount ($ counter_file) {/* returns the counter to zero. if the counter is not used, the initial value will be 1. of course you can...