首页 > 其他 > 详细

创建类以及引用一个类

时间:2015-11-18 19:34:16      阅读:256      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!