function.php代码:

<?php
    function counter(){
        $file = 'counter.txt';
        if(!file_exists($file)){
            $num = 0;
            $cf = fopen($file,"w");
            fwrite($cf,$num);
            fclose($cf);
        }else{
            $cf =fopen($file,"rw");
            $num = fgetc($cf);
            fclose($cf);
        }
        $num++;
        $cf = fopen($file,"w");
        fwrite($cf,$num);
        fclose($cf);
        return $num;
    }
?>

counter.php代码:

<?php
    require("function.php");
?>
<html>
    <head>
        <title>访客计数器</title>
    </head>
    <body>
        <h1>欢迎访问</h1>
        <br>
        <font size=7 color=red><?php echo counter();?></font>
    </body>
</html>

 

计数器只能计数到2~10区间????

相关文章:

  • 2021-07-16
  • 2021-07-14
  • 2022-12-23
  • 2021-06-17
  • 2021-10-01
  • 2021-10-03
  • 2021-11-29
猜你喜欢
  • 2022-12-23
  • 2021-12-11
  • 2022-02-28
  • 2021-11-25
  • 2021-09-14
  • 2021-11-12
  • 2021-12-18
相关资源
相似解决方案