關於smarty有關問題,求!多謝!
最後更新:2016-06-13
來源:互聯網
上載者:User
關於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><br /><body><br /><b><{$title}></b><br /></body><br /></html><br /><br /><br /><br><br />------解決方案--------------------<br />沒有設定timezone,開啟的php.ini檔案修改<br />date.timezone=Asia/Shanghai,然後重啟webserver<br />------解決方案--------------------<br />那是因為沒有設定預設時區,在PHP檔案開頭加上:<br /><dl class='code'>PHP code<pre class="brush:php;toolbar:false">date_default_timezone_set('PRC');<br />------解決方案--------------------<br />或者這樣<br /><dl class='code'>PHP code<pre class="brush:php;toolbar:false"><?date_default_timezone_set('Asia/Shanghai');include_once("Smarty/Smarty.class.php"); ......<br />------解決方案--------------------<br />這不是 smarty 的錯,而是你的php環境沒有設定好<br />php.ini 中 date.timezone 設定時區<br />或在程式中 date_default_timezone_set 函數設定時區 <li ><i class="layui-icon">