Advertisement
C_Volume2 Internet/ Browsers/ HTML #84268

counter

Shows how to create a counter, as well as record the date and time into a file.

AI

Tóm tắt bởi AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Mã nguồn
original-source
<?PHP
 // Place the location of files into variables
 $location_counter = "count.txt";
 $location_ip = "ip.txt";
 // Finds how many people have visited and adds one to it
 $counter = join('', file($location_counter));
 trim($counter);
 $counter++;
 // Print lines to the screen
 echo "<html><body><center><h1>COUNTER</h1>";
 echo "<p>You are visitor number: $counter</p>";
 echo "<p>Your IP address is: $REMOTE_ADDR</p>";
 echo "</center></body></html>";
 // Changes the value of the counter in the count.txt file
 $fp = fopen($location_counter,"w");
 fputs($fp, $counter);
 fclose($fp);
 // Adds one more ip address to the end of the ip.txt file
 $date = date("H:i:s d M, Y");
 $fp = fopen($location_ip,"a");
 fputs($fp, "Date: $date IP: $REMOTE_ADDR \n");
 fclose($fp);
?>
Bình luận gốc (3)
Được khôi phục từ Wayback Machine