Smarty3系列だとデフォルトで{php}タグが使えない
ググってみたらやたらと allow_php_tag な情報ばかり見つかるので真似してみたけど、そんなプロパティ無いって怒られる。Smarty 3.1.13 の時点では allow_php_tag は obsolete になってました。
エラー例
テンプレートファイル
<html>
{php}
$a = 10;
echo $a;
{/php}
</html>
Smartyエンジン呼び出し部分
require_once('..../smarty/libs/Smarty.class.php');
$smarty = new Smarty();
....
$smarty->display('..../hoge.tpl');
エラーログ
PHP Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template .... "{php}" unknown tag "php"' in /..../smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php:665
unknown tag、といわれましても。
対処
Smartyエンジン呼び出し部分を変更
Smarty ではなく SmartyBC を使い、php_handling に Smarty::PHP_ALLOW を設定。
require_once('..../smarty/libs/SmartyBC.class.php');
$smarty = new SmartyBC();
$smarty->php_handling = Smarty::PHP_ALLOW;
....
$smarty->display('..../hoge.tpl');