index.htm文件内容:
以下为引用的内容: {SortList} index.php内容:
|
详细分析过程:
一、$t->set_file ("Index", "index.htm"); $this->file[index] = index.htm
二、$t->set_block("Index", "RowSort", "RowsSort");
1、载入index文件index.htm内容并赋给变量$this->varvals[index]
2、$str = $this->varvals[index]获取模板文件内容
3、用preg_match_all函数来匹配模板文件中对应的block(RowSort)里的内容,并存储到$m[1][0]中
4、lock(RowSort)里的内容(包括头和尾)替换为{RowSort}
5、变量$this->varvals[RowSort] = $m[1][0] , $this->varkeys[RowSort] = /{RowSort}/
6、变量$this->varvals[index] = $str(内容已发生改变,见第4步) , $this->varkeys[index] = /{index}/
三、$t->set_var("SortList", $list_sort);
设置$this->varvals[SortList] = $list_sort
设置$this->varkeys[SortList] = /{SortList}/
四、$t->parse("RowsSort", "RowSort", true);(此操作根据sort大小重复进行)
1、利用subst函数把$this->varvals数组中的所有变量值对其中可能含有的特殊字符\和$进行处理(\和$分别替换为\\和\$,这样可以确保下一步的preg_replace不出现意外),并赋给$varvals_quoted数组
2、$str = $this->varvals[RowSort]
3、我们可以看出此时$str中含有一个{SortList},而由三:$this->varkeys[SortList] = /{SortList}/,$this->varvals[SortList] = $list_sort
4、可见经过preg_replace我们得到的$str是已经解析了PHP模板变量{SortList}之后的内容了,返回$str
5、给$this->varvals[RowSort]进行延续赋值 //这里有个问题大家可能会考虑到就是显示的时候最开始那个{RowSort}未被解析,不用担心,phplib有finish函数会对它根据你的要求进行处理
五、$t->parse("OUT", "Index");
1、可以看出,这时$this->varvals[index]中有一个PHP模板变量要进行解析,即{RowSort}
2、而在前面几步中,我们已经把$this->varvals[RowSort]的内容解析好
3、这样以来,我们把全部PHP模板变量均已解析后的内容赋给变量$this->varvals[OUT]
六、$t->p["OUT"];
显然phplib中p函数即为输出函数,我们直接把$this->varvals[OUT]输出即可
//这里要注意的是输出之前有个phplib自动进行的动作,就是对未被解析的PHP模板变量根据你的要求进行处理。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 English version
Recommended: Win version, supports code prompts!

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.