First on the code
Private Function Moldforext () {//Template single-layer for loop processing $sql= $this->sql_obj; $URL = $this->url_obj;require ($this datafile); $con = $this->moldfilecontent; $con =str_replace ("\ n", "< #tmoldbr #>", $con); $preg _for_str= "/<! \-\-\s*for\[([a-za-z_\-0-9]+):([a-za-z_\-0-9]+] \]\s*\-\-> ([^!] *) <!\-\-\s*endfor\s*\-\->/";p Reg_match_all ($preg _for_str, $con, $preg _for_match); $preg _for_num=count ($preg _for_match[0]); for ($for _tem_i=0; $for _tem_i< $preg _for_num; $for _tem_i++) {$tem _for_st= $preg _for_match[1][$for _ Tem_i]; $tem _for_ed= $preg _for_match[2][$for _tem_i];if (isset ($ $tem _for_st) &&isset ($ $tem _for_ed)) {$for _ tem_start=$ $tem _for_st, $for _tem_end=$ $tem _for_ed; $for _tem_con= ""; for ($for _tem_j= $for _tem_start; $for _tem_j<$ For_tem_end, $for _tem_j++) {$tttem _for_com= $preg _for_match[3][$for _tem_i]; $tttem _for_com=str_replace ("{". $tem _ For_st. "})", $for _tem_j, $tttem _for_com); $for _tem_con.= $tttem _for_com;} $con =str_replace ($preg _for_match[0][$for _tem_i], $for _tem_con, $con);}} $this->moldfilecontent=str_repLace ("< #tmoldbr #>", "\ n", $con);}
Actually, it's still based on regular expressions.
The For loop style written in the template is as follows
<!--For[strat:end]--> HTML code ...<!--endfor-
It is written as an HTML comment in order to prevent typographical errors when browsing only the template file.
The start of the For loop identifies the existence of the $start in the template data file, where variable variables are used inside PHP, and the value of a variable is used as a variable name.
The processing of the template engine's logical statement processing for a single layer for loop