關於smarty問題,求高手指點!!謝謝!!
求各位高手指點!不勝感激!!!
第一次接觸smarty,第一次使用時報錯;瀏覽器顯示如下: 然而重新整理一下提示資訊就沒有了,瀏覽器還是什麼都沒有輸出!
Strict Standards: strftime() [function.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
C:\AppServ\www\smarty\Smarty\Smarty_Compiler.class.php on line 400
配置如下:
smarty_inc.php
include_once("Smarty/Smarty.class.php"); //包含smarty類檔案
$smarty = new Smarty(); //建立smarty執行個體對象$smarty
$smarty->config_dir="Smarty/Config_File.class.php"; // 目錄變數
$smarty->caching=false; //是否使用緩衝,項目在調試期間,不建議啟用緩衝
$smarty->template_dir = "./templates"; //設定模板目錄
$smarty->compile_dir = "./templates_c"; //設定編譯目錄
$smarty->cache_dir = "./smarty_cache"; //快取檔案夾
//----------------------------------------------------
//左右邊界符,預設為{},但實際應用當中容易與JavaScript相衝突
//----------------------------------------------------
$smarty->left_delimiter = "<{";
$smarty->right_delimiter = "}>";
?>
index.php
include("Smarty_inc.php");
$name="初使smarty";
$smarty->assign("title",$naem);
$smarty->display("index.html");
?>
index.html
<{$title}>
------解決方案--------------------
沒有設定timezone,開啟的php.ini檔案修改
date.timezone=Asia/Shanghai,然後重啟webserver
------解決方案--------------------
那是因為沒有設定預設時區,在PHP檔案開頭加上:
PHP code
date_default_timezone_set('PRC');
------解決方案--------------------
或者這樣
PHP code
------解決方案--------------------
這不是 smarty 的錯,而是你的php環境沒有設定好
php.ini 中 date.timezone 設定時區
或在程式中 date_default_timezone_set 函數設定時區