exec 执行的是linux 的脚本命令rm 删除
-rf 包含目录、不出现删除提示(直接删除)
$counterFile 目录或文件

解决方案 »

  1.   

    thank you very much!你是我进入这个网站第一个回答我问题的人,当我看到有人给我回复时我真的非常高兴.谢谢.不过,我还想继续问一下,这是我在访客计数器函数上看到的一句话,它是这样写的:
    <?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");
    }
    ?>
    它为什么要删除这个目录呢?
      

  2.   

    exec("echo 0 > $counterFile");
    这一句是把0写入到$counterFile里么?
      

  3.   

    你的代码我看了,它的原理是:在临时目录中写一个文件,如果没有,则生成一个文件并写进去0
    (exec("echo 0 > $counterFile");)。如果有则取出来文件中的值并加1。删除文件(exec("rm -rf $counterFile");),并生成新的文件,把$num 写进去(exec("echo $num > $counterFile");)我也不太清楚为什么要这么做,一般的访问http用户的权限应该都很小,都是nobody组和用户,它的代码,没有写文件,而是把文件删除新建了一个,不知何解,是我的话我会读和写这个文件就可以了。