<?php header("Content-type: text/html; charset=utf-8"); //设置中国时区 date_default_timezone_set('PRC'); require_once("./Smarty/libs/Smarty.class.php"); $smarty = new Smarty(); $smarty->left_delimiter="<{"; $smarty->right_delimiter="}>"; $arrs=array('10010','张三','男',24,6000,300); $smarty->assign("arrs",$arrs); // var_dump($arrs); $smarty->display("./view.html"); echo "<br>-----Program is Over-----";
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>view视图文件</title> </head> <body> <{section name='i' loop=$arrs}> <{$arrs[i]}>, <{sectionelse}> there are no values in $arrs. <{/section}> </body> </html>
例子里面 name 后面的 i 没有单引号,这里试了一下,i用单引号、双引号括起来也可以,当然不用引号也行。
标签:section,smarty,delimiter,-----,一维,arrs,view From: https://www.cnblogs.com/hnqyliu/p/17369556.html