PHP template Fasttemplate Usage instructions and introduction

Source: Internet
Author: User
Tags html page php template

When you are building a site, you may have to face the following realities:

The site requires a programmer to design the program and a web designer to organize the page. So, is there a way to combine the two well?

Yes, the use of templates (fasttemplate: This program in the site's "program and Code" can be found), which will make your work easier.

Here's an explanation of the benefits of using templates:

1, in a very short period of time can replace the appearance of the entire site

2, so that programmers can abstract programming, without touching the HTML code

3, the speed is very fast

4, you can reuse the previous template

The origin of the template: Fasttemplate from the Perl package with the same name. It was ported to the PHP3 platform. All you need is a basic class file class.fasttemplate.php

To explain the difference between using a template and using the Echo or print commands to create an HTML page, echo and print are very useful when writing short scripts, but the organization and customization of the script is not good enough to be modified. Templates are much more efficient when writing a site that supports multinational languages, such as using echo and print to imagine the workload.

Do not worry, skilled use of fasttemplate will take up a part of your time, but these times will be in your future work to make up for, especially when the big project.

So, how do you use Fasttemplate?

The first step is to simply use the function

<@php
$tpl = new fasttemplate( "path");
@>

Where path points to the path where the template directory resides. This function creates a $tpl object that can then be assigned parameters, processed or used to create various pages, and so on.

Fasttemplate is based on the theory that a Web page is made up of a number of small parts. For example, Web pages are subdivided into title, page, foot, and so on. The entire page is given a variable name, each of which is given a variable name, and the smallest integral part is usually a string, and it is given a variable name. The specific processing time, is a layer of the inclusion relationship. The included section appears as a macro {name} in the previous layer. Finally, after a layer of upward output, to get the complete page.

So what is the lowest-level function to assign to a string:

<@php
$tpl->assign(name, "text");
@>

With this feature, Fasttemplate assigns the string text to the variable name, and the next level on the replaceable macro {name} content is text.

For example:

$tpl->assign (name, "Me");

This assigns the variable name to the string "me."

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.