Reply to Re: Calling a subclass's method

Your name:

Reply:


Posted by Markus Ernst on 06/14/06 12:53

Rik schrieb:
> That's what I tried, but PHP4 has thsi to say about thes second ->:
> Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting ',' or
> ';'
>
> PHP5 indeed handles this with no problems.
>
> Maybe this has something to do with returning by reference?

Indeed PHP4 passes objects by value (thus creates new instances), which
has been changed in PHP5. To pass references in PHP4 use the & character:

// & in function declaration to return reference
function &getTextBoxByID($sID) {
return $this->m_oTextBoxes[$sID];
}

// & before parameter to pass it by reference
// & with = to assign reference
function addTextBox(&$oTextBox) {
$this->m_oTextBoxes[$oTextBox->getID()] =& $oTextBox;
}

HTH
Markus

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация