<?php
$text = $_POST['a']; //从html页面传过来的a变量。
$b = array('1','2','3');
include"libs/Smarty.class.php";
$smarty = new Smarty();
$smarty->reInitSmarty(); //加载Smarty模版的初始化类,把界定符改为<{和}>,模板目录改为一个地方。
$smarty->assign("a",$b); //传递索引数组变量
$smarty->display("abc.tpl");
?>
测试$smarty.foreach:
<html>
<head>
</head>
<body>
<{foreach name=a1 from=$a item=value}>
<{$value}>
<{/foreach}>
循环次数:
<{$smarty.foreach.a1.total}> //显示3
</body>
</html>
测试$smarty.section:
<html>
<head>
</head>
<body>
<{section name=a1 loop=$a}>
<{$a[a1]}>
<{/section}>
循环次数:
<{$smarty.section.a1.total}> //显示3
</body>
</html>
测试$smarty.get:
<{$smarty.get.a}> //在地址栏中写入a的值
测试$smarty.post:
<{$smarty.post.a}> //php页面post的值
$text = $_POST['a']; //从html页面传过来的a变量。
$b = array('1','2','3');
include"libs/Smarty.class.php";
$smarty = new Smarty();
$smarty->reInitSmarty(); //加载Smarty模版的初始化类,把界定符改为<{和}>,模板目录改为一个地方。
$smarty->assign("a",$b); //传递索引数组变量
$smarty->display("abc.tpl");
?>
测试$smarty.foreach:
<html>
<head>
</head>
<body>
<{foreach name=a1 from=$a item=value}>
<{$value}>
<{/foreach}>
循环次数:
<{$smarty.foreach.a1.total}> //显示3
</body>
</html>
测试$smarty.section:
<html>
<head>
</head>
<body>
<{section name=a1 loop=$a}>
<{$a[a1]}>
<{/section}>
循环次数:
<{$smarty.section.a1.total}> //显示3
</body>
</html>
测试$smarty.get:
<{$smarty.get.a}> //在地址栏中写入a的值
测试$smarty.post:
<{$smarty.post.a}> //php页面post的值