exec函数是执行外部命令
rm -rf 是linux的命令初学就不要去管他了,这组函数很少用的

解决方案 »

  1.   

    那么 ,exec("echo $num > $couterFile");有什么作用呢
      

  2.   

    我想可能是把$num中的内容输出到$couterfile变量所指的文件中
      

  3.   

    哦,你是在看文本计数器的代码吧?
    exec("echo $num > $couterFile");
    里面的工作是把$num中的内容输出到$couterfile变量所指的文件中这种代码很古老了,可能是当时没有文件处理函数的原因。
    现在可用:
    $fp = fopen($couterfile,"w");
    fwrite($fp,$num);
    fclose($fp);
    来完成,exec需要创建新的进程,很耗时的。
      

  4.   

    但是改过之后不对呀,
    有注释的是我以前的语句,正如xuzuning(唠叨)说的很古老的代码,
    改了之后,次数不能增加,
    错误应该是没有把$num写入文件,但是fwrite($fp,$num);不对吗?<html>
    <head>
        <title>文本型计数器</title>
    </head><body><?php
    $counterFile="counter.txt";function disp($counterFile)
    {
       $fp=fopen($counterFile,"rw");
       $num=fgets($fp,6);
       fclose($fp);
     
       $num+=1;
       echo "您是本站的第".$num."位贵客";
     
       fwrite($fp,$num);
       fclose($fp);
    // exec("echo $num > $counterFile");
    }if (!file_exists($counterFile))
    {
       $fp=fopen($counterFile,"a+");
       fwrite($fp,"0");
       fclose($fp);
    // exec("echo 0 > $counterFile");
    }
    disp($counterFile);?></body></html>