On Thu, 4 Dec 2003 11:16:10 -0000, you wrote:

>I wonder if there is a simple techique to help me here. I wish to return 2
>references to objects from a function.
>
>The following code describes what I want to do but obviously will not work
>(and I understand why):
>
>function Test (&$P1, &$P2)
>{
>    $Object = new Thing();
>    $P1 =& $Object;
>    $P2 =& $Object->Property;
>}
>
>More generally is there a technique I can use for setting a referenced
>variable to be a reference?

Ok, the third line of that function is really weird. You're returning the
object anyway, so why would you want to return a property of the object? It
breaks encapsulation.

To return more than one item... have you considered simply returning an
array?

function f()
{
        return (array (7, 5));
}

list ($a, $b) = f();

I can't really see a benefit to passing in $P1 and $P2 at all, let alone by
reference... maybe you could go into more detail about what you're trying to
do? Why do you need to return a reference to the object, rather than the
object itself?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to