<html> <head> <!--set title--> <title> 访客计数器1 </title> </head> <!--show page--> <body> <?php function DisplayCounter($strFile) { //读取访问次数 if (!file_exists($strFile)) { //如果文件不存在,设置访问次数为0 $nCount = 0; //echo "file don't exist nCount = $nCount <br>/n"; } else { $fp = fopen($strFile, "rw"); $nCount = fgets($fp); //echo "file exist nCount = $nCount <br>/n"; } $nCount += 1; echo "您是第" . $nCount . "位无聊份子, 欢迎您来到从风的世界!<br>"; //删除原文件,并保存新的数据 exec("rm -rf $strFile"); exec("echo $nCount > $strFile"); } ?> <?php $strCountFile = "./count.ini"; DisplayCounter($strCountFile); ?> </body> </html>