method One:<?PHPfunctionCounter ()//Defining Functions { $five= "00000";//declare variables, $five, $four and other variables to represent the number of zeros, placed in front of the number to constitute 6 digits $four= "0000"; $three= "000"; $two= "00"; $one= "0"; $counter= "Rec.txt";//destination file for the number of accesses,. dat format if(!file_exists($counter))//determine if a file exists { $counter=fopen($counter, "W"); $num= 1; fputs($counter, "1");//Write File fclose($counter); Print"$five"."$num"; }Else{ $fp=fopen($counter, "r+"); $num=fgets($fp, "1024");//If the file exists, read the file and add 1 $num=$num+ 1; if($num< 10) Print"$five"."$num"; ElseIf($num< 100) Print"$four"."$num"; ElseIf($num< 1000) Print"$three"."$num"; ElseIf($num< 10000) Print"$two"."$num"; ElseIf($num< 100000) Print"$one"."$num"; Else Print"$num"; } $fp=fopen("$counter"," W "); fputs($fp,"$num"); fclose($fp); }?>Method Two:PHP$counter=1; if(file_exists("Rec.txt")) { $fp=fopen("Rec.txt", "R"); $counter=fgets($fp, 1024); $counter++; fclose($fp); } $fp=fopen("Rec.txt", "W"); fputs($fp,$counter); fclose($fp); Echo"<font size= ' 9 ' face= ' Verdana ' color= ' #FF0000 ' >".$counter." </font> "; ?> </B> <font size= "6" face= "Official script" > Visitors! </font> </center> </body>PHP implementation of Web site visitor statistics method (simple implementation, not anti-refresh)