If you are designing an interactive website, you will certainly focus on two main issues, namely art and programs. It is also the key element behind the construction of a website that has left its content open. There are usually two ways to reconcile the relationship between the artist and the program:
1. First do the Art page, and then by the programmer directly in the art page HTML file embedded asp, JSP, PHP and other program code.
2. The art and the program at the same time, but because there is no page frame, the program can only make some key code, the two sides completed after the art page and program code embedded composition.
In the actual site construction process, due to personnel, progress and other environmental constraints, we usually use the above two methods of coordination. However, both of these approaches have shortcomings:
1. Efficiency is not high. The poor coordination of the two may result in waiting, repeating code debugging steps, and so on;
2. Debugging is not smooth. Because the program code finally needs to embed in the HTML page, the code embedding, debugging, error correction are more cumbersome;
3. Maintenance inconvenience. Once the art design needs to be modified, such as the site revision, then all the program and HTML code mixed pages need to be rewritten;
If you are using the PHP program building site, then congratulations, PHP template technology will be more successful to solve the above problems.
So what is the template technology for PHP? The php template, Phplib, is one of the main modules in the Phplib Library, developed from the Perl templates. And Phplib is an extension on PHP, provides a lot of class library, can easily implement some basic functions such as user authentication, database encapsulation and so on. We can download the latest version from the phplib.netuse.de. To use a php template, simply unpack the Template.inc file in the Phplib package and put it in a directory that our PHP program can call.
Peel off the veil of mystery, the core concept of template technology is simply a heartbeat: to designate your artwork page as a template file, simply place the contents of the active content in the page, such as database output, user interaction, and so on, into a variable in the form {variable} in the template file corresponding to the location, when the user browses, Open the template file by the PHP program file, replace the variables defined in the template file, of course, replace the corresponding database output or user interaction, such as dynamic generation of content, for example:
Definition template file: mytemplate.html
The contents of the mytemplte.html are:
.....
...
...
We can see that, in fact, the template file is a normal HTML file, it contains the layout you want, art and other features, while the internal activity content in the form of variables, and waiting to be replaced. Obviously, the template file is directly browsed is meaningless, because it does not contain any PHP program, all the content is "dead", now let's see how to invoke the template, let it "activity" up.
http://www.bkjia.com/PHPjc/630234.html www.bkjia.com true http://www.bkjia.com/PHPjc/630234.html techarticle If you are designing an interactive website, you will certainly focus on two main issues, namely art and programs. This is also a site in the construction of the content after the most critical elements ...