Hello,

I am trying to return a reference from an object created inside a
function and at the same time have the object stored in a global
variable.

It seems that when I try doing it by assigning the object reference to a
function argument that is passed by reference, nothing is returned in
that variable despite inside the function the argument variable seems to
have the right value.

Is this a PHP bug or this is not the right way to do it?

Try the example below.

Manuel Lemos

<?
class test_class
{
        var $dummy="nothing";
};

Function not_assigning(&$not_returned,&$copy)
{
        global $object;

        $object=new test_class;
        $object->dummy="original";
        $success=1;
        $not_returned= &$object;
        $copy=$object;
        $copy->dummy="copy";
        var_dump("In the function",$success,$not_returned,$copy,$object);
        return $success;
}

$success=not_assigning($not_returned,$copy);

var_dump("Out the function",$success,$not_returned,$copy,$object);

?>

-- 
PHP Development 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