You are here: Re: Calling a subclass's method « PHP Programming Language « IT news, forums, messages
Re: Calling a subclass's method

Posted by Rik on 06/14/06 09:23

Ramon wrote:
> This is my code (in short):

> function getOuterHTML () {
> return "<input type='text' name='" . $this->m_sName . "'
> value=' . $this->m_sValue . '>";
> {


I assume the { is } in your actual code?

Try this:

<?
class TextBox {
var $m_sID;
var $m_sName;
var $m_sValue;

// Class Constructor:
function TextBox ($sID, $sName, $sValue) {
$this->m_sID = $sID;
$this->m_sName = $sName;
$this->m_sValue = $sValue;
}

function getID() {
return $this->m_sID;
}

function getOuterHTML(){
return "<input type='text' name='$this->m_sName'
value='$this->m_sValue'>";
}

}

class HTMLForm {
var $m_oTextBoxes = array();

function addTextBox($oTextBox) {
$this->m_oTextBoxes[$oTextBox->getID()] = $oTextBox;
}
}

$oTxtNumber = new TextBox ("Nr", "Number", "123");
$oForm = new HTMLForm;
$oForm->addTextBox($oTxtNumber);
echo $oForm->m_oTextBoxes["Nr"]->getOuterHTML();
?>

Works fine in PHP4 here.

Grtz,
--
Rik Wasmus

 

Navigation:

[Reply to this 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

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