有以下一段代码,在IE里运行时出错,搞的IE假死,要处理的文件命名及这段代码的程序文件都在同一文件夹下,首先排除了其他异常,估计是代码哪儿有错,但是自己找了半天也没找到原因,(哦是New Bird,嚯嚯,不怕Old Bird见笑)请高手解答一下,并指出问题所在,在下不胜感激~~~<?php
$handle = fopen($_GET["page"].".txt", "r");
while (!feof($handle)) {
$me = substr(fgets($handle, 4096),0,11);
if ($me<>"")
{
if(false === strpos($r,$me)){$somecontent.=$me."\r\n";}else{$delcontent.=$me."\r\n";}
$r.=$me."|";
}
}
fclose($handle);
$handle = fopen("重复用户.txt", 'wb');
fwrite($handle, $delcontent);
fclose($handle);
$handle = fopen("正常用户.txt", 'wb');
fwrite($handle, $somecontent);
fclose($handle);
?>

解决方案 »

  1.   

    你的函数strpos用错了吧,if(false === strpos([color=#00FF00]$r,$me)){$somecontent.=$me."\r\n";}else{$delcontent.=$me."\r\n";}[/color]
    $r没定义就直接在strpos中用,不知道你是想从谁中找谁,看看strpos参数顺序是否对了
      

  2.   

    $_GET["page"].".txt"  文件是否存在? 其他地方好像没有问题
      

  3.   

    如果php5以上的话,可用file_put_contents写
    ,你这段代码我看没有错啊,是不是你的环境有问题? ie假死一般和js有关...这个没其他东西?
      

  4.   

    现在用的环境是appServ
    PHP是5.0以上的版本怎么修改?
      

  5.   

    从这段代码看 出现ie假死应该是程序陷入了死循环 极大可能是没有找到测试文件
    建议先用固定的文件测试一下 
    先不急用$_GET["page"].".txt"
      

  6.   


    if(file_exists($_GET["page"].".txt")){
    $handle = fopen($_GET["page"].".txt", "r");
    $r=array();
    $somecontent="";
    $delcontent="";
    while (!feof($handle)) {
    $me = substr(fgets($handle, 4096),0,11);
    if ($me!=""){
    if(!in_array($r,$me)){$somecontent.=$me."\r\n";}else{$delcontent.=$me."\r\n";}
    $r[]=$me;
    }
    }
    fclose($handle);
    $handle = fopen("重复用户.txt", 'wb');
    fwrite($handle, $delcontent);
    fclose($handle);
    $handle = fopen("正常用户.txt", 'wb');
    fwrite($handle, $somecontent);
    fclose($handle);
    }else{
    exit("No File!");
    }
      

  7.   

    if(!in_array($r,$me))
    改为:
    if(!in_array($me,$r)){
      

  8.   

    $r定义就是起码有个值,php中直接使用没错,但没有值的话怎么使用strpos查找位置。