书上不一定就对,尤其是国内的书,呵呵比如漏了$str的赋值,以及int fopen ( string filename, string mode [, int use_include_path])

解决方案 »

  1.   

    对不起,$str_array=expolde("||",$str);//这句我打错了。
    $str_array=expolde("||",$fd)
      

  2.   

    对不起,上面代码有些问题。
    从新写一下。主要是一个计数器,他是一段取得用户IP,进行判断,确定访问人数的增加。问题是在数组上的操作看不懂。部分代码如下:
    function counter()
    {
    global $suerip;
    $counterFile="count.txt";//保存访问量信息文件
    $fd=fopen($counterfile,"rw");
             $str=fread($fd,100);
    $str_array=expolde("||",$str);
    while (list($key,$value)=each($str_arry))
    {
    $count[$key]=$value;
    }
    fclose($fd);
    $num=$count[0];
    $ip=$count[1];
    $num=$num+1;
    $fd=fopen($counterfile,"w");
    fputs($fd,$num||$userip");
    fclose($fd);
    echo "$num";
    //问题是str_array里在做expolde时已经取得了数组,直接用$str_array不就可以了,为什么还要做一个同样的$count数组?
    }