shmop建立共享内存后,怎么也不能清空,我试验了两种方法都不行
一种测试方法是:
$intKey=1234;
$intLength=12;
$strValue1="abcdefg";
$strValue2="33";$intShmopId=shmop_open($intKey,"c",0666,$intLength) ;
shmop_write($intShmopId,$strValue1,0);
shmop_delete($intShmopId);
shmop_close($intShmopId);$intShmopId=shmop_open($intKey,"w",0666,$intLength) ;
shmop_write($intShmopId,$strValue2,0);
$strResult=shmop_read($intShmopId,0,$intLength);
shmop_close($intShmopId);
echo $strResult;//这里的输出结果是333456第二种方法:
$intKey=1234555;
$intLength=12;
$strValue1="abcdefg";
$strValue2="33";$intShmopId=shmop_open($intKey,"c",0666,$intLength) ;
for($i=0;$i<$intLength;$i++)
 {
    shmop_write($intShmopId,"",$i);

  }
shmop_close($intShmopId);$intShmopId=shmop_open($intKey,"w",0666,$intLength) ;
shmop_write($intShmopId,$strValue2,0);
$strResult=shmop_read($intShmopId,0,$intLength);
shmop_close($intShmopId);
echo $strResult;//这里的输出结果还是是333456请问这是怎么回事?

解决方案 »

  1.   

    你不是把值读到$strResult里面了
      

  2.   

    怎么没有把值读到$strResult呢?,此话怎讲?
      

  3.   

    不好意思,打错了,两次输出的结果都是33cdefg
      

  4.   

    看看这个bug是否和你的情况相同http://bugs.php.net/bug.php?id=33011
      

  5.   

    再自己顶一下,把问题重申一遍:shmop建立共享内存后,怎么也不能清空,我试验了两种方法都不行 
    一种测试方法是: 
    $intKey=1234; 
    $intLength=12; 
    $strValue1="abcdefg"; 
    $strValue2="33"; $intShmopId=shmop_open($intKey,"c",0666,$intLength) ; 
    shmop_write($intShmopId,$strValue1,0); 
    shmop_delete($intShmopId); 
    shmop_close($intShmopId); $intShmopId=shmop_open($intKey,"w",0666,$intLength) ; 
    shmop_write($intShmopId,$strValue2,0); 
    $strResult=shmop_read($intShmopId,0,$intLength); 
    shmop_close($intShmopId); 
    echo $strResult;//输出的结果都是33cdefg第二种方法: 
    $intKey=1234555; 
    $intLength=12; 
    $strValue1="abcdefg"; 
    $strValue2="33"; $intShmopId=shmop_open($intKey,"c",0666,$intLength) ; 
    for($i=0;$i <$intLength;$i++) 

        shmop_write($intShmopId,"",$i);   } 
    shmop_close($intShmopId); $intShmopId=shmop_open($intKey,"w",0666,$intLength) ; 
    shmop_write($intShmopId,$strValue2,0); 
    $strResult=shmop_read($intShmopId,0,$intLength); 
    shmop_close($intShmopId); 
    echo $strResult;//这里的输出结果还是33cdefg请问这是怎么回事?4楼说的也我也看了,但是还是不能最终解决问题,多次试验表明,在WINDOWS2003、WINDOWS XP系统下,shmop_delete清空不了内存块,但是我用循环的方法调用shmop_write(见方法二),向内存中写入空值,也写不进去,真是无能为力了。
      

  6.   

    第二种方法5.2.9-1测试通过
    你的php什么版本
      

  7.   

    不好意思,这两天忙,没上线,总的来说我已经对shmop绝望了,用了其他的方法。
    给分了。