Home > Backend Development > PHP Tutorial > smarty中无法用section循环

smarty中无法用section循环

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 14:01:53
Original
1074 people have browsed it

smarty php html

php中代码:

 include("global.php");

   $name[]=array("name"=>"新闻");
   $name[]=array("name"=>"新闻2");
   $title="php100";
   $smarty->assign("title",$title);
   $smarty->assign("name",$name);
   $smarty->display("index.htm");

?>
HTM中代码

{$title}

{section name=list,loop=$name}

{$name[list].name}
{/sectiom}



如果只引用title可以正常调用,循环就报错
错误提示:
Fatal error: Uncaught --> Smarty Compiler: Syntax error in template ".\templates\index.htm" on line 4 "{section name=list,loop=$name}" missing "loop" attribute 

回复讨论(解决方案)

{section name=sn loop=$news}
Copy after login
Copy after login


中间是空格不是逗号

{section name=sn loop=$news}
Copy after login
Copy after login


中间是空格不是逗号
{section name=list loop=$name}
Copy after login

没用,然后{section name=list loop=$name}
{$name[list].name}
{/sectiom}三句下面都是黄色波浪线

{section name=list,loop=$name}{$name[list].name}{/section}
Copy after login

section你拼写错了 不是sectiom

{section name=list loop=$name}{$name[list].name}{/section}
Copy after login

这样应该可以了

坑爹啊有木有~~

谢谢

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template