phplib中的一些基本语法和函数_MySQL
bitsCN.com
语法介绍:
phplib中常用的方法有set_file,set_block,set_var,parse,ppasre,p,get等。
声明:由于本系统采用的是phplib,如果页面中有大括号对,这将会替换成空白,所以在写此文章时,用"[[","]]"来替代大括号。大家在用的时候是用大括号便是,此处仅为写文章方便而作此约定。
set_file:是用来引入模板文件。
用法:
$t->set_file("show_main","main.htm");
或
$t->set_file(array(
"show_header"=>"header.htm",
"show_main"=>"main.htm"
));
set_block:用来声明一个区块
用法:
$t->set_block("show_main","rowlist","RL");
稍微解释一下,show_main是用set_file取得的文件句柄,rowlist是模板页面中的区域标识一般如下方式来写
[[param]] |
如上是将
区块是可以嵌套的
[[param]] |
如上所示,这声明一个嵌套区块,这在boeiBlog的像册部分采用了这种方式,有兴趣的朋友可以找出来看看
对于嵌套的模板,我们可以这样来使用
$t->set_block("show_main","rowlist","RL"); // 里面的参数从前向后依次是包含的关系,最后一个是别名,主要用来区块识别
$t->set_block("rowlist","collist","CL"); // 第一个参数是外层块的名称,第二个是自己的名乐,第三个是别名
循环这样的区块时要特别注意
如下:
$t->set_block("show_main","rowlist","RL");
$t->set_block("rowlist","collist","CL");
for($i=0;$i {
$t->set("CL");// 这里要对追加的列循环执行一次清理,否则会多出一堆东西
for($ii=0;$ii {
$t->set_var("param","boeiBlog");
$t->parse("CL","collist",true);// true参数表明这是追加
}
$t->parse("RL","rowlist",true);// 这里的true也是表追加
}
上述代码将会产生一个5X5的表格,每个单元格里会出现一个boeiBlog
set_var:用来作变量替换
上述代码里的$t->set_var("param","boeiBlog");就是把模板中的param变量替换成boeiBlog这个字符串,当然也可以替换成变量,如:
$curdate = date("Y-m-d");
$t->set_var("param",$curdate);
set_var也有追加属性,如:
$curdate = date("Y-m-d");
for($i=0;$i {
$t->set_var("param","
".$curdate,true);
}
这将产生十个连续的当前日期
有时候可以用set_var的追加属性来替代block的循环.
set_var是可以用数组的,如:
$t->set_var(array(
"param"=>"boeiBlog",
"title"=>"柏艾网络"
));
模板如下:
[[param]],[[title]] |
parse:用于解析文件
当我们将模板中的所有变量都处理完之后,可以用parse一将这个模板进行解析。这是模板处理的最后几道工序。
如:
$t->set_file("show_index","index.htm");
$t->set_file("show_main","main.htm");
$t->set_var("param","boeiBlog");
$t->parse("main","show_main");
我们所用的模板可能是:
main.htm
[[param]] |
如果此时还有另外一个模板,其结构如下:
index.htm
[[main]]
那么上述代码将会把main.htm中的变量替换成boeiBlog后再放到index.htm中的main处,最后形成一个在标签中的表格
解析完成之后便是输出页面,
p:用于输出页面
如:
$t->set_file("show_index","index.htm");
$t->set_file("show_main","main.htm");
$t->set_var("param","boeiBlog");
$t->parse("main","show_main");
$t->parse("index","show_index");
$t->p("index");// 此处便会将整个index页面输出,注意main.htm已经被嵌入到index.htm,所以不用$t->p("main");
pparse:同p一样也用来输出页面
如:
上述代码可以如下简化
$t->set_file("show_index","index.htm");
$t->set_file("show_main","main.htm");
$t->set_var("param","boeiBlog");
$t->parse("main","show_main");
$t->pparse("index","show_index");// 此处将p和parse结合到一起,立即完成解析并输出
get:用于获得文件内容
如:
$t->set_file("show_index","index.htm");
$t->set_file("show_main","main.htm");
$t->set_var("param","boeiBlog");
$t->parse("main","show_main");
$t->parse("index","show_index");
$getstr = $t->get("index");
echo $getstr;// 你将会看到这实际上和p是一样的。
利用get,我们可以轻松的取得生成页面的内容,这可以用于静态页面的生成。可以看到phplib用来处理静态页面是非常方便的 bitsCN.com

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to type braces in word? When we use word, we will encounter the need to use braces. I believe that many users do not know how to create braces. Let this site carefully introduce to users how to enter braces in Word documents. How to enter braces in a Word document 1. Click Insert: Open the WORD document and click "Insert-Shape" on the menu bar. 2. Select brackets: drop-down list, click on the brace, there are three types of double braces and left and right braces in the shape list, here select the left brace. 3. View the results: Move the mouse to the target location and draw the opening brace.

1. How can you make money by publishing articles on Toutiao today? How to earn more income by publishing articles on Toutiao today! 1. Activate basic rights and interests: original articles can earn profits by advertising, and videos must be original in horizontal screen mode to earn profits. 2. Activate the rights of 100 fans: if the number of fans reaches 100 fans or above, you can get profits from micro headlines, original Q&A creation and Q&A. 3. Insist on original works: Original works include articles, micro headlines, questions, etc., and are required to be more than 300 words. Please note that if illegally plagiarized works are published as original works, credit points will be deducted, and even any profits will be deducted. 4. Verticality: When writing articles in professional fields, you cannot write articles across fields at will. You will not get appropriate recommendations, you will not be able to achieve the professionalism and refinement of your work, and it will be difficult to attract fans and readers. 5. Activity: high activity,

In this article, we will learn how to add articles in HTML5. One of the new segmentation elements in HTML5 is the tag. Articles are represented in HTML using tags. More specifically, the content contained within the element is different from the rest of the site's content (even though they may be related). Let us consider the following example to understand how to add an article in HTML5 Example 1 In the following example, we are using inline styles in the article element. <!DOCTYPEhtml><html><body><articlestyle="width:300px;border:2pxsolidgray;padding:

How to understand @VitalikButerin’s new article’s thoughts on Ethereum’s expansion? Some people say that Vitalik’s order for Blob Inscription is outrageous. So how do blob packets work? Why is the blob space not being used efficiently after the upgrade in Cancun? DAS data availability sampling in preparation for sharding? In my opinion, the performance of Cancun is usable after the upgrade, and Vitalik is worried about the development of Rollup. Why? Next, let me talk about my understanding: As I have explained many times before, Blob is a temporary data package that is decoupled from EVM calldata and can be directly called by the consensus layer. The direct benefit is that EVM does not need to access the Blob when executing transactions. data, thus resulting in lower execution layer computations

1. Open your phone, click on the WeChat software, and enter the WeChat home page settings. 2. Find [My] in the lower right corner of WeChat, open it, and enter the [My] page. 3. Click Collection and then open a new page.

DedeCMS is a powerful open source content management system that is widely used in various website construction. However, sometimes article content may disappear during use, which causes trouble to website operators. This article will introduce to you the common reasons and quick solutions for the disappearance of article content in DreamWeaver CMS, and provide specific code examples, hoping to help you solve this problem. 1. Possible reasons for the disappearance of article content: database operation error: the table storing article content in the database may

DedeCMS is a powerful open source website content management system that is deeply loved by the majority of website builders. However, during use, article content may sometimes be lost, which causes considerable trouble to website administrators. This article will introduce a method to solve the problem of missing article content in DreamWeaver CMS, and provide specific code examples, hoping to help website administrators who encounter this problem. Description of the problem: In the process of using Dreamweaver CMS, sometimes the content of articles is lost. possible

Toutiao Search Express software not only provides a wealth of article content for users to browse, but also provides a platform for users to express themselves and share knowledge. Many users would like to know whether publishing articles in Toutiao Search Express Edition can make money, so today the editor of this site will introduce in detail whether publishing articles in Toutiao Search Express Edition can make money and how to publish articles. I hope it can help everyone in need. Is there any profit from publishing articles on Toutiao Search Express? Answer: Yes. 1. First, we open the Toutiao search speed version software. On the homepage, we click the [plus icon] in the upper right corner; 2. Then we will come to the page for publishing articles, where we can upload videos, photos, links, and enter text. Wait, everything is set up
