大家好,在学习smarty模板foreach()时候遇到这个问题,搞了很久都不知道哪里出错了?抓狂啊!求高手解决!
u.php文件<?phpinclude_once('smarty/configs/smarty_inc.php');$infobook=array("object"=>"...
u.php文件
<?php
include_once('smarty/configs/smarty_inc.php');
$infobook=array("object"=>"book","type"=>"computer","name"=>"PHP从入门到精通","publishing"=>"清华大学出版社");
$title="使用foreach循环输出数组内容";
$smarty->assign('title','$title');
$smarty->assign('infobook','$infobook');
$Smarty->display('u.tpl');
?>
--------------------------------------------------------------------------
模板文件:u.tpl
使用foreach语句循环输出数组:
{%foreach key=key item=item from=$infobook%}
{%key%}=>{%$item%}<br />
{%/foreach%}
--------------------------------------------------------------------
错误:
Fatal error: Call to a member function display() on a non-object in E:\wamp\www\u.php on line 7 展开
<?php
include_once('smarty/configs/smarty_inc.php');
$infobook=array("object"=>"book","type"=>"computer","name"=>"PHP从入门到精通","publishing"=>"清华大学出版社");
$title="使用foreach循环输出数组内容";
$smarty->assign('title','$title');
$smarty->assign('infobook','$infobook');
$Smarty->display('u.tpl');
?>
--------------------------------------------------------------------------
模板文件:u.tpl
使用foreach语句循环输出数组:
{%foreach key=key item=item from=$infobook%}
{%key%}=>{%$item%}<br />
{%/foreach%}
--------------------------------------------------------------------
错误:
Fatal error: Call to a member function display() on a non-object in E:\wamp\www\u.php on line 7 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询