index.htm File Contents:
The following are the referenced contents:
<body> <!--BEGIN Rowsort--> {sortlist}<br> <!--end Rowsort--> </body>
index.php content: ? $t->set_file ("Index", "index.htm"); $t->set_block ("Index", "Rowsort", "Rowssort"); .............................................. ... $list _sort ......................... $t->set_var ("Sortlist", $list _sort); $t->parse ("Rowssort", "Rowsort", true); .............................................. .............................................. $t->parse ("Out", "Index"); $t->p ("Out"); ?> |
Detailed analysis Process:
First, $t->set_file ("Index", "index.htm"); $this->file[index] = index.htm
Second, $t->set_block ("Index", "Rowsort", "Rowssort");
1, loading the index file index.htm content and assigned to the variable $this->varvals[index]
2, $str = $this->varvals[index] Get template file contents
3, with the Preg_match_all function to match the template file in the corresponding block (rowsort) content, and stored in the $m[1][0]
4, Lock (Rowsort) contents (including headers and tails) replaced with {Rowsort}
5, variable $this->varvals[rowsort] = $m [1][0], $this->varkeys[rowsort] =/{rowsort}/
6, variable $this->varvals[index] = $str (content has changed, see step 4th), $this->varkeys[index] =/{index}/
Third, $t->set_var ("Sortlist", $list _sort);
Set $this->varvals[sortlist] = $list _sort
Set $this->varkeys[sortlist] =/{sortlist}/
Four, $t->parse ("Rowssort", "Rowsort", true);(This operation is repeated according to the sort size)
1, using the SUBST function of all the variables in the $this->varvals array of the value of which may contain special characters \ and $ processing (\ and $ are replaced by \ and \$ respectively, so as to ensure that the next preg_replace is not unexpected), and assigned to $ varvals_quoted Array
2, $str = $this->varvals[rowsort]
3, we can see that at this time $str contains a {sortlist}, and by three: $this->varkeys[sortlist] =/{sortlist}/, $this->varvals[sortlist] = $list _ Sort
4, visible after preg_replace we get $str is already parsed the PHP template variable {sortlist} content, back to $str
5, to $this->varvals[rowsort] carry on the continuation assignment//Here is a question you may consider is the beginning of the display of the {Rowsort} has not been resolved, do not worry, phplib have the finish function on it according to your request for processing
V. $t->parse ("Out", "Index");
1, you can see that at this time $this->varvals[index] there is a PHP template variable to be parsed, that is, {rowsort}
2, and in the previous steps, we have $this->varvals[rowsort] content of the good
3, since then, we have all PHP template variables have been parsed content assigned to the variable $this->varvals[out]
Six, $t->p["out"];
Obviously the P function in Phplib is the output function, we can directly output the $this->varvals[out]
Note here is the output before the Phplib automatic action, is not parsed PHP template variables according to your request for processing.