|
Posted by Vince Morgan on 05/07/07 02:07
"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
news:xMGdnWvEq_C8eKDbnZ2dnUVZ_uqvnZ2d@comcast.com...
> Vince Morgan wrote:
> > I guess I don't understand how references work in php;
> > Calling a class member function below as an example;
> > function &getRow()
> > {
> > return odbc_fetch_array($this->_det);
> > }
> > I would expect that I should end up with nothing as there is nothing to
> > actualy reference.
>
> But you do have something to reference. odbc_fetch_array returns an
> array, and you are returning a reference to that array.
>
If it passing an array to $var then it isn't behaving as a reference, at
least not as I understand it. It would be behaving as though I had
requested passing the array itself in the call wouldn't it?
> No surprise at all. It should work that way.
Why is that?
> It won't in C++ or Java if odbc_fetch_array returns a reference.
I would have thought that the '&' modifier would do the same in php too
Jerry.
> All a variable is is a place to keep something to use later. You don't
> need to use it again in this function, so there's no need to create a
> variable. Just return the array directly, as is being done.
Yes, it is assigning an array evidently, rather than a reference to an array
so that would mean that the request for a reference it being ignored here?
Regards,
Vince
Navigation:
[Reply to this message]
|