|
作者: jxwfh [jxwfh] 论坛用户 | 登录 |
我需要一个非常简单的php计数器,越简单越好了,而且是每刷新 一次计数都会加的,由于本人只会asp,so请各位懂php高人的帮帮忙, |
地主 发表时间: 04-06-24 18:04 |
回复: freek [freek] 论坛用户 | 登录 |
以下有经典的两个例子(PHP3) <html> <head> <title>访客计数器 原型</title> </head> <body> <?php /* simple access counter for php3 (c)1998 David W. Bettis dbettis@eyeintegrated.com medify by Wilson Peng */ $counterFile = "/tmp/counter.txt"; function displayCounter($counterFile) { $fp = fopen($counterFile,"rw"); $num = fgets($fp,5); $num += 1; print "您是第 "."$num"." 位无聊份子"; exec( "rm -rf $counterFile"); exec( "echo $num > $counterFile"); } if (!file_exists($counterFile)) { exec( "echo 0 > $counterFile"); } displayCounter($counterFile); ?> </body> </html> Copyright © 1998 David W. Bettis <?php //--------------------------- // 访客计数器函数 MyCounter() // Author: Wilson Peng // Copyright (C) 1999 //--------------------------- function MyCounter() { $counterFile="/tmp".$GLOBALS["PHP_SELF"]; if (!file_exists($counterFile)) { if (!file_exists(dirname($counterFile))) { mkdir(dirname($counterFile), 0700); } exec("echo 0 > $counterFile"); } $fp = fopen($counterFile,"rw"); $num = fgets($fp,5); $num += 1; print "$num"; echo $counterFile; exec("rm -rf $counterFile"); exec("echo $num > $counterFile"); } ?> Copyright © 1999, Wilson Peng 摘自<<PHP中文手册>>, |
B1层 发表时间: 04-06-25 08:45 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号