Home  >  Article  >  Backend Development  >  Basic concepts about PHP template technology_PHP tutorial

Basic concepts about PHP template technology_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:04:32707browse

If you are designing an interactive website, the two main issues you will definitely be concerned about are art and programming. This is also the most critical element in the construction of a website after putting aside its content. There are usually two ways to coordinate the relationship between artists and programs:
1. Make the art page first, and then the programmer directly embeds ASP, JSP, PHP and other program codes in the HTML file of the art page.
 
 2. The art and program are carried out at the same time, but because there is no page frame at this time, the program can only make some key codes. After both parties are completed, the art page and program code will be embedded and synthesized.

In the actual website construction process, due to environmental constraints such as personnel and schedule, people usually use a mixture of the above two coordination methods. However, both methods have shortcomings:
 1. Inefficiency. Poor coordination between the two may result in waiting, repeated code debugging steps, etc.;
 2. Poor debugging. Since the program code ultimately needs to be embedded in the HTML page, the embedding, debugging, and error correction of the code are relatively cumbersome;
 3. Maintenance is inconvenient. Once the art design needs to be modified, such as website revision, then all mixed pages of programs and HTML codes need to be rewritten;
If you are using PHP programs to build websites, then congratulations, PHP template technology will solve the above problems more satisfactorily .

So what is PHP template technology? PHP template is PHPlib's Template technology. It is one of the main modules in the PHPLIB library and is developed from Perl's Template. PHPLIB is an extension on PHP, providing many class libraries that can easily implement some basic functions such as user authentication, database encapsulation, etc. We can download the latest version at phplib.netuse.de. To use PHP templates, just unpack the template.inc file in the PHPLIB package and put it in a directory that our PHP program can call.

Peeling away the mystery, the core concept of template technology is heart-poundingly simple: to designate your art page as a template file, you only need to add active content on the page such as database output, user interaction, etc. Variables defined in the form {variable} are placed in the corresponding location in the template file. When the user browses, the template file is opened by the PHP program file and the variables defined in the template file are replaced. Of course, the corresponding database output is replaced. Or dynamically generated content such as user interaction, for example:
Define template file: Mytemplate.html
The content of Mytemplte.html is:
;body> It contains the layout, art and other elements you want, while the internal active content exists in the form of variables and is waiting to be replaced. Obviously, it is meaningless to browse the template file directly, because it does not contain any PHP program, and all the content is "dead". Now let's take a look at how to call the template and make it "active".





http://www.bkjia.com/PHPjc/445207.html

www.bkjia.com

true

http: //www.bkjia.com/PHPjc/445207.htmlTechArticleIf you are designing an interactive website, you will definitely pay attention to two main issues, namely art and programming. This is also the most critical element of a website after putting aside its content during construction...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn