|
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]
|