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>");
?>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to