PHP Smarty
è¨å®š
ライブラリ
https://www.smarty.net/
é…ç½®
ライブラリ
smarty-X.X.X
 └demo
 └libs
  └Smarty.class.php
  └他
コンパイルファイルé…ç½®å ´æ‰€
compile
テンプレートファイルé…ç½®å ´æ‰€
template
 └test.tpl
テンプレート
※test.tpl
<!DOCTYPE html>
<html>
<head>
 <meta charset="UTF-8">
 <title>~</title>
</head>
<body>
 埋ã‚è¾¼ã¿ç”¨å¤‰æ•°
 <p>{$val1}</p>
 <p>{$val2}</p>
</body>
</html>
テンプレート利用
※~.php
<?php
require_once '~/smarty-X.X.X/libs/Smarty.class.php';
$smarty = new Smarty();
テンプレートファイルé…ç½®å ´æ‰€æŒ‡å®š
$smarty->template_dir = '~/template';
コンパイルファイルé…ç½®å ´æ‰€æŒ‡å®š
$smarty->compile_dir = '~/compile';
テンプレートファイルã®å¤‰æ•°ã¸å€¤ã‚’埋ã‚è¾¼ã¿
$smarty->assign('val1', 999);
$smarty->assign('val2', 'aaa');
æç”»
$smarty->display('test.tpl');