<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>访客统计</title> </head> <body> <?php if (!@$fp=fopen("count.txt", "r")){ //open the file in read-only mode; this step is optional and depends on the actual situation. echo "count.txt文件创建成功!<br />"; } @$num=fgets($fp,12);//read 11 digits if ($num=="")$num=0;//if the content of count.txt is empty, initialize it to 0 $num++; //increment the view count by 1 @fclose($fp); $fp=fopen("count.txt", "w");//open the file in read-only mode fwrite($fp, $num); //write the result after adding 1 fclose($fp); //close the file echo "您是第".$num."位浏览者!"; ?> </body> </html>