<?php
class Table {
private $row;
private $col;
private $border;
private $width;
public function __construct($row, $col, $border, $width) {
$this->row = $row;
$this->col = $col;
$this->border = $border;
$this->width = $width;
}
public function create_table($row, $col, $border, $width) {
header("content-type:text/html; charset=utf-8");
$data = ‘<table border="‘.$this->border.‘" width="‘.$this->width.‘">‘;
for($row = 0; $row<$this->row; $row++) {
$data .= ‘<tr>‘;
for($col = 0; $col<$this->col; $col++) {
$data .= ‘<td>‘.($row+1).‘行‘.($col+1).‘列‘.‘</td>‘;
}
$data .= ‘</tr>‘;
}
$data .= ‘</table>‘;
return $data;
}
}
$table = new Table(5, 5, 2, 800);
echo $table->create_table();
?>
时间: 2024-10-20 01:49:25