Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-13 11:47:22
Original
924 people have browsed it

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

source:php.cn
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!