PHP访客计数器
<?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; } ?>
本程序使用时需要上传至相应目录,然后在显示访客人数的页面加入以下代码:
require_once"count.php";
$guestsnum=num();
echo"您是第".$guestsnum."位访客";
相关推荐
mathchao 2020-10-28
zyyjay 2020-11-09
xuebingnan 2020-11-05
samtrue 2020-11-22
stefan0 2020-11-22
yifangs 2020-10-13
songshijiazuaa 2020-09-24
hebiwtc 2020-09-18
天步 2020-09-17
83911535 2020-11-13
whatsyourname 2020-11-13
zhouyuqi 2020-11-10
Noneyes 2020-11-10
王志龙 2020-10-28
wwwsurfphpseocom 2020-10-28
diskingchuan 2020-10-23
savorTheFlavor 2020-10-23