We often see the statistical code of many Web sites are displayed in the form of JS calls, let's look at how that example.
-
- $countfile = "Num.txt";//the file that the definition counter writes to is count.txt in the current directory, and then we should test whether the file can be opened
- if ($fp = fopen ($countfile, "R")) = = False) {//Open file in read/write mode, exit if not open
- printf ("Open file%s failed!", $countfile);
- Exit
- }else{
- $count = Fread ($fp, 10);//If the file can be opened normally, read the data in the file, assuming it is 1
- $count = $count 1; Read 10-bit data
- Fclose ($FP);//close the current file
- $fp = fopen ($countfile, "w");//Open file in overwrite mode
- Fwrite ($fp, $count);//write new data after adding 1
- Fclose ($FP);//and close the file
- Echo document.write (". $count.") n;//output data in javascript form
- }
- ?>
- Inside the HTML file, JS calls the method.
- Example Page Detach counter
- Hello, you are the first
- -Visitor
http://www.bkjia.com/PHPjc/486253.html www.bkjia.com true http://www.bkjia.com/PHPjc/486253.html techarticle we often see the statistical code of many Web sites are displayed in the form of JS calls, below we will look at how the example of it. PHP $countfile = "num.txt";//define counter write ...