ここではSmartyのインストールを解説していきます。

ダウンロードはこちら
http://www.smarty.net/download
設置
Smarty/libsフォルダをドキュメントルート直下に設置します。
cache , templates , templates_c フォルダをプロジェクト内に作成します。
(例ではSmartyフォルダにlibsの中身を置いています)
パスを通す
<?PHP
// 読み込み
require_once('Smarty/Smarty.class.php');
// オブジェクト作成
$smarty = new Smarty();
// ディレクトリ設定
$smarty->template_dir = 'smarty/templates';
$smarty->compile_dir = 'smarty/templates_c';
$smarty->cache_dir = 'smarty/cache';
// 表示データをアサイン
$smarty->assign('hoge', 'Hello world');
// テンプレート表示
$smarty->display('index.tpl');
Smarty.class.phpを読み込み、オブジェクトを生成後、cache , templates , templates_c フォルダのパスを通します。
アサインした変数の利用法
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta content="86400" http-equiv="Expires"/>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<title>Smarty</title>
</head>
<body>
{$hoge}
</body>
</html>
ファイルの拡張子は.tplです。
{$hoge}でアサインした変数が使用できHello worldと出力されます。
※注意
cache , templates_cにはキャッシュが書き込まれるので、書き込み権限が必要になります。
私はレンタルサーバーではパーミッションを777にしています。
