Portál AbcLinuxu, 12. května 2025 07:54
$this->foo2->foo3
class Table { private $rows = array(); public function addRow($cell_count) { $row = new Row(); for($i = 0; $i < $cell_count;$i++) array_push($this->rows, $row); return $row; } public function getRow($i) { return $this->rows[$i]; } public function getCell($i, $j) { return $this->rows[$i]->getCell($j); } } class Row { private $cells = array(); public function addCell() { $cell = new Cell(); array_push($this->cells, $cell); return $cell; } public function getCell($i) { return $this->cells[$i]; } } $table = new Table(); $table->addRow(10); $cell = $table->getCell(0, 5);
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.