调试环境:easyphp 5.3.0
问题描述:模板只显示数组的第一列,其他的不显示PHP代码:
<?php
require_once('config/config.php');$arr = array(
array('id'=>5,'title'=>'title1'),
array('id'=>8,'title'=>'title2'),
array('id'=>3,'title'=>'title3')
);
$smarty->assign('news',$arr);
$smarty->display('test.htm');
?>模板部分代码:
<HTML><HEAD>
<TITLE>测试</TITLE>
</HEAD>
{section name=n loop=$news}
<{$news[n].title}>
<{$news[n].id}><br>
没有数据
{/section}
</html>显示结果: <5>
没有数据 <8>
没有数据 <3>
没有数据
问题描述:模板只显示数组的第一列,其他的不显示PHP代码:
<?php
require_once('config/config.php');$arr = array(
array('id'=>5,'title'=>'title1'),
array('id'=>8,'title'=>'title2'),
array('id'=>3,'title'=>'title3')
);
$smarty->assign('news',$arr);
$smarty->display('test.htm');
?>模板部分代码:
<HTML><HEAD>
<TITLE>测试</TITLE>
</HEAD>
{section name=n loop=$news}
<{$news[n].title}>
<{$news[n].id}><br>
没有数据
{/section}
</html>显示结果: <5>
没有数据 <8>
没有数据 <3>
没有数据
<TITLE>测试</TITLE>
</HEAD>
<{section name=n loop=$news}>
<{$news[n].title}>
<{$news[n].id}><br>
没有数据
<{/section}>
</html>
<> <5>
<> <8>
<> <3>
<>
<TITLE>测试</TITLE>
</HEAD>
{section name=n loop=$news}
{$news[n].id}<br>
{$news[n].titlex} 没有数据
{/section}
</html>
<TITLE>测试</TITLE>
</HEAD>
{section name=n loop=$news}
{$news[n].id}<br>
{$news[n].titlex} 没有数据
{/section}
</html>
<TITLE>测试</TITLE>
</HEAD>
{section name=n loop=$news}
{$news[n].id}<br>
{$news[n].title}
{/section}
</html>
谢谢