File sharing

From: Date: Wed, 24 Oct 2001 18:22:59 +0000
Subject: File sharing
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-72125@lists.php.net to get a copy of this message
I'm trying to access an object as a Singleton. Here is the source code I'm using. The problem is that the member objFile from the $test variable is set to an open file in the class constructor. It works fine, but when I recover it from the memory, the file handler gets lost in starts being considered an int. Has anyone done this before ? <?php echo("<html><body>"); include ("./ConcreteErrorLog/SingletonTest.inc"); $test = new Singleton; $test->testCreateSingleton(); echo("Creating shared memory.<br>"); $attachkey=1; $memorykey = shm_attach($attachkey); $variablekey=1; echo("Getting variable from memory. <br>"); $test2=shm_get_var($memorykey,$variablekey); echo("Got the variable " . get_class($test2) . " <br>"); if(!isset($test2) || empty($test2)){ echo("Putting in memory. <br>"); shm_put_var($memorykey,$variablekey,$test); $test->testCreateSingleton(); } echo("The variable must be there by now. <br>"); $test =& shm_get_var($memorykey,1); echo("Got it. <br>"); echo("member is now = " . $test->intMember . "<br>"); $test->testCreateSingleton(); if($HTTP_GET_VARS["clear"]=="yes"){ echo("Will remove shared object. <br>"); shm_remove_var($memorykey,$variablekey); echo("Shared object removed. <br>"); } echo("</body></html>"); ?>

« previous php.general (#72125) next »