码迷,mamicode.com
首页 > 其他好文 > 详细

创建类以及引用一个类

时间:2015-11-18 19:34:35      阅读:117      评论:0      收藏:0      [点我收藏+]

标签:

 

<?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();

 


?>

创建类以及引用一个类

标签:

原文地址:http://www.cnblogs.com/xiuxiu123/p/4975455.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!