저는 Procedural php에서 5 년입니다. 최근에 나는 총알을 물기로 결정하고 OOP로 진행합니다. 지금 나는 이것이 내가 지금까지 무엇을 가지고이 클래스는 그리드 내가이올바른 방법으로 클래스를 만드는 법
$grid = new Grid();
// a span is an area the father and the widget is the son, so spans have widgets inside.
// a span a width of 6
$span1 = $grid->span("6");
// a new widget inside span1
$span1->widget("icon", "title1", "content1");
// another new widget inside span1
$span1->widget("icon", "title2", "content2");
// a span a width of 4
$span2 = $grid->span("4");
// a new widget inside span2
$span2->widget("icon", "title1", "content1");
// another new widget inside span2
$span2->widget("icon", "title2", "content2");
// echo /return results
$grid->render();
을 할 수 있도록하고자하는 반응 관리자 템플릿 을 관리하는 기본 UI 클래스를 만들 triyng 만 해요 나는 어떻게 처신해야할지 모르겠다.
class Grid{
private $content;
private $innerContent;
private $spanResult;
private $widgetResult;
function span($size){
$this->size = $size;
$output = '<div class="span' . $size . '">';
$output .= $this->innerContent;
$output .= '</div>';
$this->spanResult .= $output;
}
function widget($icon, $title, $content){
$output = '<div class="widget widget-nopad">';
$output .= '<div class="widget-header"> <i class="icon-' . $icon . '"></i>';
$output .= '<h3>' . $title . '</h3>';
$output .= '</div>';
$output .= '<div class="widget-content">';
$output .= $content;
$output .= '</div>';
$output .= '</div>';
$this->widgetResult = $output;
}
function render(){
}
}
감사합니다.
코드 검토 –
에 게시해야합니다. 지금 막 거기에 게시 된 사람이 많지 않습니다. –
이 질문은 [code review] (http://codereview.stackexchange.com) – sjagr