Re: Unable to return object references from functions

From: Date: Mon, 17 Dec 2001 06:00:00 +0000
Subject: Re: Unable to return object references from functions
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-77911@lists.php.net to get a copy of this message
Hello, Tom Rogers wrote: > > Hi > What is the scope of the array that holds the object ? global > Maybe a bit of code to show what you are after :) It is to implement another function that will return a reference (not a copy) of a object stored in a global array passing the index of the array. It would be like this, except that this code does not work as I need: $objects=array(); Function CreateObject(&$index) { global $objects; $index=count($objects); $objects[$index]=new my_class; } Function GetObject($index,&$object) { global $objects; $object= &$objects[$index]; } CreateObject($index); GetObject($index,$my_object); Regards, Manuel Lemos > Tom > > At 03:37 PM 17/12/01, Manuel Lemos wrote: > >Hello, > > > >Tom Rogers wrote: > > > > > > Hi again > > > Got a bit sidetracked ... here is your original code :) > > > >Thanks, I managed to make it work for me similarly to that. > > > >Now, a different problem, I already have array variable with a object. > >Is there a way to make a function return a reference to that object in a > >variable passed by reference to a function?

« previous php.general (#77911) next »