This article describes how to remotely use PHP text counters. We all know the powerful functions of PHP. using it, you can easily write a text-type counter, but this can only be used at the site where you can run the PHP program, we all know how to use PHP's powerful functions. using it, you can easily write a text-type counter, but this can only be used at the site where you can run the PHP program, how can I use PHP on websites that you cannot run? Please refer to the following link:
In fact, this uses a JavaScript document. write function to display the count.
Insert an html language where you need the counter. Below
It is the source program of counter. php.
//--------------------------------------------------------------------
// Text counter
// Author: Xu Xiaodong (chinlone)
// Home: http://lthx.126.com
// E-mail: chinlone@china.com
// Oicq: 4703122
//--------------------------------------------------------------------
$ CounterFile = "counter.txt"; // file name
If (! File_exists ($ counterFile )){
$ Fp = fopen ($ counterFile, "a"); // Create a counter.txt file if it does not exist.
Fwrite ($ fp, "0"); // write the value 0 back to the file.
Fclose ($ fp); // close the file
}
$ Fp = fopen ($ counterFile, "r"); // open the counter.txt file as a reader
$ Num = fgets ($ fp, 9); // The Row indicated by the read object pointer (the first line) is 9 and the value is paid to the num variable.
Fclose ($ fp); // close the file
$ Num ++; // The value is increased by 1.
$ Fp = fopen ($ counterFile, "w + ");
Fwrite ($ fp, $ num); // write the new value back to the file
Fclose ($ fp); // close the file
Echo "document. write ($ num)"; // use the document. write function of JavaScript
Number to display our count
?>
Run the following command in apache + PHP4.0:
...