foreach和section都会报 Notice: Undefined index
我想问一下,为啥我的就会报警告 foreach和section都会报 Notice: Undefined index: cancelOrder in H:\StudyProgram\wamp\www\SmartyTest\libs\ORG\Smarty\sysplugins\smarty_internal_templatebase.php(165) : eval()'d code on line 32
代码:
controller
<?php
class orderController{
function show(){//控制器的作用是调用模型,并调用视图,将模型产生的数据传递给视图,并让相关视图去显示。
global $view;
//$testModel = new testModel();
//$orderModel = M('order');
//$cancelArray = $orderModel->getCancelOrder();
//$testView = V('test');
//$testView -> display($data);
$cancelArray = array(
array('objectId' =>1 ,
'installmentNo' =>2 ),
array('objectId' =>2 ,
'installmentNo' =>1 )
);
print_r($cancelArray);
$view ->assign('cancelArray',$cancelArray);
$view ->display('order.tpl');
}
}
?>
tpl
<foreach item=cancelOrder from=$cancelArray >
{$cancelOrder.objectId}
{$cancelOrder.installmentNo}
<br />
</foreach>