|
Posted by gosha bine on 05/07/07 08:50
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.
Are you debugging with E_ALL? This actually should throw a notice ("only
variables can be returned by ref" or similar).
> If I assign the reference as below;
> $var = getRow()
> and then echo the result;
> echo $var['name'];
> echo $var['address'];
> it all works fine, which surprises me somewhat.
> In other languages I have more experience with this would throw an error, or
> leave you with a reference to nothing, however in php 5 I can use this
> variable hereon without a problem.
> Does php make a copy of the result if there is no var to actualy pass a
> reference to?
> I can't see how it isn't.
> An explaination of this would be very appreciated.
> TIA,
> Vince
>
>
--
gosha bine
extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
Navigation:
[Reply to this message]
|