<?php // PHP访客计数器 function num() { if(!file_exists("n.txt")) { $fp=fopen("n.txt","w"); fwrite($fp,"1"); fclose($fp); $n=1; } else { $fp=fopen("n.txt","r"); $n=fgets($fp); fclose($fp); $n++; $fp=fopen("n.txt","w"); fwrite($fp,$n); fclose($fp); } return $n; } ?>
When using this program, you need to upload it to the corresponding directory, and then add the following code to the page that displays the number of visitors:
require_once"count.php";
$guestsnum=num();
echo"You are the ".$guestsnum. "Visitor";