Page 1 of 1
PHP 4 function references
Posted: Sun Mar 18, 2007 8:43 pm
by alex.barylski
This is what I have and it works as I get a actual reference to the object when I call it's methods, everything works fine...
I want to wrap this functionality in a inline method such as
Regardless of where I put the reference operator, nothing seems to work in PHP4???
Code: Select all
&getObject(){ return &$this->_object; }
Is this not possible in PHP 4??? What the hell am I doing wrong?
Sorry for sounding impatient but I just spent the better half of 3-4 hours trying to figure out why my code wasn't working as expected, the whole time it has to do with damn references
Thanks

Posted: Sun Mar 18, 2007 11:06 pm
by feyd
You still need the "&" as part of the assignment.
Posted: Sun Mar 18, 2007 11:31 pm
by alex.barylski
feyd wrote:You still need the "&" as part of the assignment.
Hey feyd, I swear I tried that already, but I'll give it another go
Thanks dude

Re: PHP 4 function references
Posted: Mon Mar 19, 2007 4:35 am
by Chris Corbyn
Hockey wrote:Code: Select all
&getObject(){ return &$this->_object; }
You only need one reference operator here:
Code: Select all
&getObject(){ return $this->_object; }
The & on the function declaration already states that the function returns a reference
