xizi2002 (☆☆戏☆子☆☆)  ☆
你是想送点分给我们吧!好啊。

解决方案 »

  1.   

    赫赫,怎么会有这种错误提示呢?这个函数是php3.06-php4都可以用的。
      

  2.   

    晕倒,不是,我真的出现了这种情况,在别人的服务器上也出现了这种情况,很奇怪呵.具体程序
    index.php
    <?  
    class SharedMem{  
        var $SemaphoreID;  
        var $SharedMemID;  
        var $VarIndexes;  
        function SharedMem(){  
            $this->SemaphoreID = sem_get(1000,1,0600);  
            $this->SharedMemID = shm_attach(2000,65535,0600);  
            sem_acquire($this->SemaphoreID);  
            $this->VarIndexes = @shm_get_var($this->SharedMemID,0);  
            if(empty($this->VarIndexes)){  
                $this->VarIndexes = array();  
                shm_put_var($this->SharedMemID,0,$this->VarIndexes);  
            }  
            sem_release($this->SemaphoreID);  
        }      //取出存在共享内存中的某变量,返回false表示共享内存中无该变量  
        function read($name){  
            if(!isset($this->VarIndexes[$name])) return false;  
            $GLOBALS[$name] = shm_get_var($this->SharedMemID,$this->VarIndexes[$name]);  
            return true;  
        }      //将指定变量存入共享内存  
        function save($name){  
            if(!isset($this->VarIndexes[$name])){  
                $this->VarIndexes[$name] = count($this->VarIndexes)+1;  
                shm_put_var($this->SharedMemID,0,$this->VarIndexes);  
            }  
            shm_put_var($this->SharedMemID,$this->VarIndexes[$name],$GLOBALS[$name]);  
        }  
    }  
    ?> 
    test.php
    <?   
    include("index.php");  
    $test = new SharedMem();  
    $abc = '123';  
    $test->save('abc');  
    unset($abc);  
    $test->read('abc');  
    print $abc;  
    ?>  
    演示:
    http://www.yu.40it.com/test/test.php