歡迎來到小豬圈!

2007-06-01

Smarty 學習筆記初篇

只要include到Smarty.class.php就好,不需增加目錄到 include_path 也可以使用。

將定界符改掉(預設是大括號{}),建議用兩個字元以上,這樣可以減少跳脫(escape)的麻煩。前後加上HTML的註解符號,可以讓模版獨立預覽(除了嵌入檔案、<title>與屬性值之外,對網頁影嚮較少),對於設計者也比較方便。

require_once('x:/realpath/Smarty-2.6.17/libs/Smarty.class.php');
$smarty = new Smarty();
$smarty->left_delimiter = '<!--{';
$smarty->right_delimiter = '}-->';
$a = 'This is a title';
$smarty->assign('title', $a);
$smarty->display('index.tpl.html');
PHP Strict: Timezone = Asia/Taipei

由於我在php.ini有設定error_reporting = E_ALL | E_STRICT。所以安裝Smarty 的時候出現 strict 錯誤訊息:

Strict Standards: strftime(): It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for '8.0/no DST' instead in XXX\Smarty-2.6.17\libs\Smarty_Compiler.class.php on line XXX

到 php.ini 設定 date.timezone = Asia/Taipei 就好。

No comments:

Post a Comment

Comment Form Message

標籤分類

Blog Archive

Labels

Google Analytics Tracking Code

About Me

My photo
Keelung, R.O.C, Taiwan
一個不學無術、混吃等死的傢伙…