解析[6] :网页计数器的原理
下面就是 MyCounter() 函式。为了让读者方便了解,程式中的变数
$counterFile、$fp 及 $num 保持和 David W. Bettis 所设定的计数器中的变数功能相同。
<?php
file://---------------------------
// 访客计数器函式 MyCounter()
// Author: Wilson Peng
// Copyright (C) 1999
file://---------------------------
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
$counterFile、$fp 及 $num 保持和 David W. Bettis 所设定的计数器中的变数功能相同。
<?php
file://---------------------------
// 访客计数器函式 MyCounter()
// Author: Wilson Peng
// Copyright (C) 1999
file://---------------------------
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
中国海量技术资料网站超级搜索
本站声明
- 如果您发现链接错误,请通知我们,不胜感激。
- 如果您认为本站文章侵犯您的版权,请通知我们,我们将立即删除。
- 本站提供的文章收集连接于其他网站,版权归作者所有。
- 本站的文章仅供学习和研究之用,严禁用于商业用途。
最新统计
- 文章中心总数:51611篇
- 今日更新文章:0篇
- 本周更新文章:0篇
- 备用更新文章:10篇

