Smartyのバージョン {$smarty.version}
広告
テンプレートファイルを処理しているSmartyのバージョン情報は{$smarty.version}で参照します。
{$smarty.version}
テンプレートファイル内での記述例は次のようになります。
Smartyのバージョンは {$smarty.version} です。
サンプルプログラム
では簡単なサンプルプログラムを作成して試してみます。
<?php
require_once('Smarty.class.php');
$smarty = new Smarty();
$smarty->template_dir = 'd:/smartysample/reserve/templates/';
$smarty->compile_dir = 'd:/smartysample/reserve/templates_c/';
$smarty->config_dir = 'd:/smartysample/reserve/configs/';
$smarty->cache_dir = 'd:/smartysample/reserve/cache/';
$smarty->assign('title', '予約変数のテスト');
$smarty->display('sample2-1.tpl');
?>
上記を「sample2-1.php」の名前で「(Apacheドキュメントルート)¥smarty¥reserve」に保存します。
{* Smarty reserve/sample2-1.tpl *}
<html>
<head>
<title>Smarty Test</title>
</head>
<body>
<h1>{$title}</h1>
<p>このサイトはSmarty version{$smarty.version} で作成されています。</p>
</body>
</html>
上記を「sample2-1.tpl」の名前で「D:¥smartysample¥reserve¥templates」に保存します。
そしてブラウザから「http://localhost/smarty/reserve/sample2-1.php」へアクセスして下さい。
( Written by Tatsuo Ikura )
PHPBook