*index.php

<?php
$tpl=new Template;
$tpl->define(array(
  'contents'  =>'index.tpl',
	'body'  =>'inc/body.tpl',
));

$data = sql_list("쿼리내용");
$tpl->assign('data', $data);
$tpl->print_('body');

*index.tpl

<ul>
	{@ data}	
	<li>hi{.seq}</li>
    {/}
</ul>

tpl에 php 구문을 넣어도 에러는 나지 않습니다만 tpl 파일은 View(V)만을 하기 때문에 PHP 구문이 필요 없습니다.

@ 로 loop문을 대체하고 있습니다.

{/}는 end입니다.

{.seq}는 data에 있는 배열명입니다.

 

'tech > PHP' 카테고리의 다른 글

특정 날짜의 요일 구하기  (0) 2023.10.07
영문, 숫자만 체크(유효성 검사)  (0) 2023.10.04
템플릿 언더바(Template Underscore) #1  (0) 2023.10.02
LG xpay 결제 모듈 연동 모바일  (0) 2018.03.19
카카오톡 API  (0) 2017.11.30

+ Recent posts