電子書籍の厳選無料作品が豊富!

smarty3 でエラーが発生しています。

現在自宅のサーバーでsmarty3を勉強しているのですが以下のエラーで困っています。
詳しい方ご教授お願いします。

環境 :
CentOS 6.3
PHP 5.3.3
Smarty 3.1.13

読み込んでいるファイル
test.php

1 <?php
2 ini_set('display_errors', 1);
3 ini_set('date.timezone','Asia/Tokyo');
4 define('SMARTY_DIR', 'Smarty/libs/');
5 require_once( SMARTY_DIR. 'Smarty.class.php');
6
7 $smarty = new Smarty();
8
9 $smarty->template_dir = '../templates/';
10 $smarty->compile_dir = '../templates_c/';
11 $smarty->config_dir = '../config/';
12 $smarty->cache_dir = '../cache/';
13
14 $msg = "テストを表示します";
15 $smarty->assign('msg', $msg);
16
17 $smarty->display('test.tpl');
18
19
20 ?>

テンプレートファイル
1 <html>
2 {$msg}
3 </html>

表示されるエラー文
Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "../templates/test.tpl" on line 2 "{$msg}" unknown tag "private_print_expression"' in /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php:665 Stack trace: #0 /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php(451): Smarty_Internal_TemplateCompilerBase->trigger_template_error('unknown tag "pr...', 2) #1 /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_internal_templateparser.php(2353): Smarty_Internal_TemplateCompilerBase->compileTag('private_print_e...', Array, Array) #2 /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_internal_templateparser.php(3101): Smarty_Internal_Templateparser->yy_r27() #3 /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_internal_templateparser.php(3201): Smarty_Internal_Templateparser->yy_reduce(27) #4 /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_intern in /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php on line 665

テンプレートファイルの{$msg}を削除して動作させるとコンパイルされてはいるようです。

よろしくお願いします。

A 回答 (2件)

以下の事例が現象(というかエラーメッセージ)が似てるな



http://www.smarty.net/forums/viewtopic.php?p=69968

『なんてこった、サーバ上の「templates_c」ディレクトリにパーミンション777を設定してみたんだ。そしたらちゃんと動いた』
だと。

>テンプレートファイルの{$msg}を削除して動作させるとコンパイルされてはいるようです。
という事なので、現象は違うかも知れないが…念のためパーミッションの確認を。

他にも、『/libs/sysplugins ディレクトリをちゃんとアップしてないか、パーミッションの関係で読みとれてないんじゃねえの?』と推測している人も居るようなので、その点も確認してみてください。
    • good
    • 0

>9 $smarty->template_dir = '../templates/';


>10 $smarty->compile_dir = '../templates_c/';
>11 $smarty->config_dir = '../config/';
>12 $smarty->cache_dir = '../cache/';
原因はこれ。
どうしてこの部分かは、日本語のリファレンスと英語のリファレンスを見比べると
どうしてかがわかる。
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!