PHP - 访客计数器

php 代码

<?php
        $counterFile = "counter.txt";
        function displayCounter($counterFile) {
        $fp = fopen($counterFile,"rw");
        $num = fgets($fp,4096);
        $num += 1;
        print "您是第 " . $num . " 位小朋友";
        exec( "rm -rf $counterFile");
        exec( "echo $num > $counterFile");
                }
        if (!file_exists($counterFile)) {
            exec( "echo 0 > $counterFile");
            }
        displayCounter($counterFile);
?>

参考

返回文章列表 打赏
本页链接的二维码
打赏二维码
期待你的评论