在smarty中的非对象上调用成员函数assign()

时间:2014-11-08 13:58:26

标签: php smarty

this is my php file and i have error in line no 3 
Fatal error: Call to a member function assign() on a non-object in D:\trainee\xampp\htdocs\traineeproject\sil1online\bottom.php on line 3 

当我每次使用此会话变量时都会给我错误...

<?php
date_default_timezone_set("Asia/Kolkata");
$smarty->assign("s_activId",isset($_SESSION['s_activId'])   ? $_SESSION['s_activId'] : ");
$smarty->assign("l_tital",$l_tital);
$smarty->assign("l_home",$l_home);
$smarty->assign("l_billBook",$l_billBook);
$smarty->assign("l_addBillBook",$l_addBillBook);
?>

1 个答案:

答案 0 :(得分:1)

此处未定义$smarty个对象。

您应该在设置时区之后:

require 'smarty/Smarty.class.php';
$smarty = new Smarty();

能够使用Smarty方法