亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

做到time()的時候出問題了

報錯

Notice: Undefined index: time in?D:\tools\xampp\htdocs\MVC\smarty\sysplugins\smarty_internal_templatebase.php(171) : eval()'d code?on line?27

Notice: Trying to get property of non-object in?D:\tools\xampp\htdocs\MVC\smarty\sysplugins\smarty_internal_templatebase.php(171) : eval()'d code?on line?27


這是代碼test.php

<?php

require('../smarty/Smarty.class.php');

$smarty = new Smarty();

//配置

$smarty->left_delimiter="{";

$smarty->right_delimiter="}";

$smarty->template_dir="tpl";

$smarty->compile_dir="template_c";

$smarty->cache_dir="cache";


$smarty->caching=true;

$smarty->cache_lifetime=120;



$smarty->assign('time',time());

$smarty->display('test.tpl');

--------------------------------------

這是 test.tpl

{$time}

--------------------------------------

剛接觸,自己解決不了了

正在回答

1 回答

time() 先賦值給變量,然后再 assign

0 回復 有任何疑惑可以回復我~
#1

Inoodlest 提問者

學習了! :)
2015-05-02 回復 有任何疑惑可以回復我~
#2

小王子抓貓咪 回復 Inoodlest 提問者

新版本的smarty可以不用預先定義變量,你這樣寫是可以運行的。同時date_format默認就會將時間轉換為當前你所在的時區時間格式Jun 15, 2016 當然如果你定義了格式%A,%B %e,%Y %H:%M:%S 會顯示Wednesday,June 15,2016 23:53:06 我用的是3.1.29
2016-06-15 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

做到time()的時候出問題了

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號