Hi all,
Sorry to present you all with another boring problem but I've spent
all day trying to get this to work with no success.
Below is a function to which I pass the argument &$myCell (which is an
instance of my class "Cell"). I am not sure whether it is necessary
or desirable to use the '&' and I've noticed that this subject seems
to be a source of considerable debate in this group (is this the
method used implicitly in java?).
My problem here is that the lines;
$html .= $newCell->getAttributes();
$html .= $newCell->getData();
do not work. They refer to functions within the Cell class but the
error that comes up is;
Fatal error: Call to a member function on a non-object
function addCell(&$myCell)
{
$html="<td>";
$html .= $newCell->getAttributes();
$html .= $newCell->getData();
return $html .= "</td>";
}
If it should help in identifying the problem, the remainder of this
class is printed below. Thanks for your help ;-)
Andy
--------------------------------------------------------------------------
//test data
$testTable = new Table('border="1" summary="Test table"');
$c1 = new Cell("skdj", "bgsdlr");
$c2 = new Cell('jzhb', 'sjbvf');
$c3 = new Cell('zjskdbv', 'jsdbsjkv');
$c4 = new Cell('jzsdcg', 'zkdjbd');
$r1 = array($c1, $c2);
$r2 = array($c3, $c4);
$testTable->startTable();
$testTable->addRow($r1);
$testTable->addRow($r2);
$testTable->stopTable();
//Table Class
class Table
{
var $attributes;
function Table($attributes="")
{
$this->attributes = $attributes;
}
function startTable()
{
echo $html = "<table " .$this->attributes . "\n";
}
function stopTable()
{
echo $html = "</table>";
}
function addRow($newRow)
{
$html="<tr>";
for( $i ; $i < count($newRow) ; $i++ )
{
$cells=$newRow[i];
$html .=$this->addCell($cells);
}
echo $html .="</tr>";
}
}
?>