객체 지향 PHP를 사용할 때 HTML을 어디에 렌더링해야합니까?객체 지향 PHP 디자인에서 HTML을 어디에서 렌더링해야합니까?
비즈니스 프로세스에는 고객 레코드를 유지 관리하는 몇 가지 조치가 포함됩니다.
각 비즈니스 프로세스의 렌더링이 별도의 PHP 파일을 가져야합니까? 즉. viewCustomerTransactions.php?
여기 코드는 어디에 있어야합니까?
$custTrans = Customer.getTransactions();
foreach ($custTrans as $ct){
$amount = $ct[0];
$date = $ct[1];
$product = $ct[2];
echo '<div class="custTrans">';
echo '<span class="custTransAmount">'.$amount.'</span>';
echo '<span class="custTransDate">'.$date.'</span>';
echo '<span class="custTransproduct">'.$product.'</span>';
echo '</div>';
}
아마도 codeigniter와 같은 MVC 프레임 워크가 더 좋을까요?
$custTrans = Customer.getTransactions();
$html = "";
foreach ($custTrans as $ct){
$amount = $ct[0];
$date = $ct[1];
$product = $ct[2];
$html .= "<div class="custTrans">";
$html .= "<span class='custTransAmount'>".$amount."</span>";
$html .= "<span class='custTransDate'>".$date."</span>";
$html .= "<span class='custTransproduct'>".$product."</span>";
$html .= "</div>";
}
당신은 다음 변수 $ html로 저장이 HTML 데이터를 가지고 당신은 그것을 어디 에코 수 있습니다 내가 당신이라면
가능한 중복 : http://stackoverflow.com/questions/316509/where PHP 코드 예제 –
예제가 OO PHP와 아무런 관련이 없습니다. 배열을 통과하고 배열과 에코 결과를 보거나, MVC가 렌더링과 데이터를 잘 구분할 수 있습니다. 개인적으로 CI – bensiu
+1을 MVC 용으로 사랑합니다. 그리고 저는 CI를 좋아합니다. – polarblau