Heim  >  Artikel  >  Backend-Entwicklung  >  解析smarty模板中类似for的功能实现_PHP教程

解析smarty模板中类似for的功能实现_PHP教程

WBOY
WBOYOriginal
2016-07-21 15:05:00838Durchsuche

1. 功能说明,在页面使用smarty循环100次输出,类似for循环100次
{section name=total loop=100}
{$smarty.section.total.index+1} //当前的索引
{$smarty.section.total.iteration} //用于显示循环的次数
{/section}

{assign var=i value=0}
{section name=total loop=100}
{assign var=i value=$i+1} {$i}     //使用assign的方式赋值
{/section}

输出结果:  1 2 3 4 5 ... ... 100

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/327712.htmlTechArticle1. 功能说明,在页面使用smarty循环100次输出,类似for循环100次 {section name=total loop=100} {$smarty.section.total.index+1} //当前的索引 {$smarty.section.t...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn